Advertisement
enos

gambar.vb

Jul 25th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.04 KB | None | 0 0
  1. Public Class gambar
  2.  
  3.     Public Shared Function GetGrayScale(ByVal pic As Bitmap) As Double(,)
  4.         Dim tmp(pic.Width - 1, pic.Height - 1) As Double
  5.         Dim w As New Bitmap(pic.Width, pic.Height)
  6.         For i As Integer = 0 To pic.Height - 1
  7.             For j As Integer = 0 To pic.Width - 1
  8.                 Dim warna As New Color
  9.                 warna = pic.GetPixel(j, i)
  10.                 Dim grey As Integer = (CInt(warna.R) + warna.G + warna.B) / 3
  11.                 tmp(i, j) = grey
  12.  
  13.             Next
  14.         Next
  15.         Return tmp
  16.     End Function
  17.     Public Shared Function GetPictArray(ByVal pic As Bitmap) As Double(,)
  18.         Dim tmp(pic.Width - 1, pic.Height - 1) As Double
  19.         Dim w As New Bitmap(pic.Width, pic.Height)
  20.         For i As Integer = 0 To pic.Height - 1
  21.             For j As Integer = 0 To pic.Width - 1
  22.                 Dim warna As New Color
  23.                 warna = pic.GetPixel(j, i)
  24.                 tmp(i, j) = warna.R
  25.             Next
  26.         Next
  27.         Return tmp
  28.     End Function
  29.  
  30. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement