Tugas Pengolahan Citra 3 (vb.net program)
- ..
Tampilan gambar sebelum di edit :
a)
b)
A.Point Operation:
1. Biner
Private Sub BinerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BinerToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = CInt(.GetPixel(Y, X).R) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = CInt(.GetPixel(Y, X).G) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = CInt(.GetPixel(Y, X).B) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
Grey = (Red + Green + Blue) / 3 'konversi warna pada pixel Y,X ke grey
If (Grey < 128) Then
Red = 0
Green = 0
Blue = 0
Else
Red = 255
Green = 255
Blue = 255
End If
bmap.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Biner : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Biner berhasil"
End Sub
Private Sub MBitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MBitToolStripMenuItem.Click
Dim m As Integer
Dim mbit As Integer
m = InputBox("masukkan nilai MBit", "Input")
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = CInt(.GetPixel(Y, X).R) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = CInt(.GetPixel(Y, X).G) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = CInt(.GetPixel(Y, X).B) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
Grey = (Red + Green + Blue) / 3 'konversi warna pada pixel Y,X ke grey
mbit = m ^ 2 * Int(Grey / 2 ^ m)
bmap.SetPixel(Y, X, Color.FromArgb(mbit, mbit, mbit)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Mbit : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Mbit berhasil"
End Sub
Hasil Running :
2. MBit
Private Sub MBitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MBitToolStripMenuItem.Click
Dim m As Integer
Dim mbit As Integer
m = InputBox("masukkan nilai MBit", "Input")
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = CInt(.GetPixel(Y, X).R) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = CInt(.GetPixel(Y, X).G) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = CInt(.GetPixel(Y, X).B) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
Grey = (Red + Green + Blue) / 3 'konversi warna pada pixel Y,X ke grey
mbit = m ^ 2 * Int(Grey / 2 ^ m)
bmap.SetPixel(Y, X, Color.FromArgb(mbit, mbit, mbit)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Mbit : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Mbit berhasil"
End Sub
Hasil Runing :
3.Brigthness
Private Sub BrigthnessToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrigthnessToolStripMenuItem.Click
Dim m As Integer
m = InputBox("Masukan Nilai Brightness", "Prikitiew...")
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = CInt(.GetPixel(Y, X).R) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = CInt(.GetPixel(Y, X).G) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = CInt(.GetPixel(Y, X).B) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
Grey = (Red + Green + Blue) / 3 'konversi warna pada pixel Y,X ke grey
If (Red + m > 255 Or Green + m > 255 Or Blue + m > 255) Then
Red = 255
Green = 255
Blue = 255
Else
Red = Red + m
Green = Green + m
Blue = Blue + m
End If
bmap.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Brigthness : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Brigthness berhasil"
End Sub
Hasil Running :
4.Contrast
Private Sub ContrastToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContrastToolStripMenuItem.Click
Dim m As Integer
m = InputBox("Masukan Nilai Contrast", "Prikitiew...")
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = CInt(.GetPixel(Y, X).R) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = CInt(.GetPixel(Y, X).G) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = CInt(.GetPixel(Y, X).B) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
Grey = (Red + Green + Blue) / 3 'konversi warna pada pixel Y,X ke grey
If (Red * m > 255 Or Green * m > 255 Or Blue * m > 255) Then
Red = 255
Green = 255
Blue = 255
Else
Red = Red * m
Green = Green * m
Blue = Blue * m
End If
bmap.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Contrast : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Brigthness berhasil"
End Sub
Hasil Running :
5. Inversi
Private Sub InversiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InversiToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
Dim inVal As Object
inVal = InputBox("Berapa Bit ? ", "Inversi", "8")
If inVal <> "" Then
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim mBit, Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
mBit = CInt(inVal)
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = CInt((Math.Pow(2, mBit) - 1)) - CInt(.GetPixel(Y, X).R) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = CInt((Math.Pow(2, mBit) - 1)) - CInt(.GetPixel(Y, X).G) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = CInt((Math.Pow(2, mBit) - 1)) - CInt(.GetPixel(Y, X).B) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
If (Red > 255) Then
Red = 255
Else
If Red < 0 Then
Red = 0
End If
End If
If Green > 255 Then
Green = 255
Else
If Green < 0 Then
Green = 0
End If
End If
If Blue > 255 Then
Blue = 255
Else
If Blue < 0 Then
Blue = 0
End If
End If
bmap.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Contrast Scale : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Inversi Scale berhasil"
End If
End Sub
Hasil Running :
6. Logaritmik
Private Sub LogaritmikToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogaritmikToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
Dim tL As Object
tL = InputBox("Masukan Nilai C : ", "Transformasi Logaritmik", "0")
If tL <> "" Then
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim c, Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
c = CDbl(tL)
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = c * Math.Log(CInt(.GetPixel(Y, X).R) + 1) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = c * Math.Log(CInt(.GetPixel(Y, X).G) + 1) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = c * Math.Log(CInt(.GetPixel(Y, X).B) + 1) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
If (Red > 255) Then
Red = 255
Else
If Red < 0 Then
Red = 0
End If
End If
If Green > 255 Then
Green = 255
Else
If Green < 0 Then
Green = 0
End If
End If
If Blue > 255 Then
Blue = 255
Else
If Blue < 0 Then
Blue = 0
End If
End If
bmap.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Negative Image Scale : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Transformasi Logaritmik berhasil"
End If
End Sub
Hasil Running :
7.Power Law
Private Sub PowerLawToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PowerLawToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
Dim plC As Object
plC = InputBox("Masukan nilai c : ", "Power Law Transformation", "0")
If plC <> "" Then
Dim plY = InputBox("Masukan nilay y : ", "Power Law Transformation", "0")
If plY <> "" Then
bmap = New Bitmap(picAwal.Image) 'Gambar asli dijadikan gambar Bitmap
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image) 'deklarasi gambar Bitmap dari gambar asli untuk diproses
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer, Grey As Integer
Dim X, Y As Integer
Dim yPL, cPL As Double
cPL = CDbl(plC)
yPL = CDbl(plY)
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With tempbmp
For X = DX To .Height - DX - 1
For Y = DY To .Width - DY - 1
Red = cPL * Math.Pow(CInt(.GetPixel(Y, X).R), yPL) 'ambil nilai warna merah (Red) pada pixel(Y,X)
Green = cPL * Math.Pow(CInt(.GetPixel(Y, X).G), yPL) 'ambil nilai warna hijau (Green) pada pixel(Y,X)
Blue = cPL * Math.Pow(CInt(.GetPixel(Y, X).B), yPL) 'ambil nilai warna biru (Blue) pada pixel(Y,X)
If (Red > 255) Then
Red = 255
Else
If Red < 0 Then
Red = 0
End If
End If
If Green > 255 Then
Green = 255
Else
If Green < 0 Then
Green = 0
End If
End If
If Blue > 255 Then
Blue = 255
Else
If Blue < 0 Then
Blue = 0
End If
End If
bmap.SetPixel(Y, X, Color.FromArgb(Red, Green, Blue)) 'simpan warna baru pada pixel(Y,X)
Next
If X Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = "Progres Proses Negative Image Scale : " & Int(100 * X / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * X / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Pengolahan Citra : Proses Transformasi Power Law berhasil"
End If
End If
End Sub
8. Smoothing
Private Sub SmoothingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SmoothingToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical +
MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
Dim MF(2, 2) As Double
'MaskFilter.Show()
'matriks Filter
' 0 1 2
'0 a b c
'1 d e f
'2 g h i
'Filter smoothing
MF(0, 0) = 1 / 9 'a
MF(0, 1) = 1 / 9 'b
MF(0, 2) = 1 / 9 'c
MF(1, 0) = 1 / 9 'd
MF(1, 1) = 1 / 9 'e
MF(1, 2) = 1 / 9 'f
MF(2, 0) = 1 / 9 'g
MF(2, 1) = 1 / 9 'h
MF(2, 2) = 1 / 9 'i
bmap = New Bitmap(picAwal.Image)
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image)
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer
Dim i As Integer, j As Integer
Dim k As Integer, l As Integer 'untuk mask border
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With bmap
For i = DX To .Height - DX - 1
For j = DY To .Width - DY - 1
'proses matriks filter
'point(j,i)*e --> titik tengah
Red = CInt(.GetPixel(j, i).R) * MF(1, 1)
Green = CInt(.GetPixel(j, i).G) * MF(1, 1)
Blue = CInt(.GetPixel(j, i).B) * MF(1, 1)
'proses titik tetangga
'point(j-1,i-1)*a--> MF(0,0)--> titik kiri atas
If j - 1 < 1 And i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i - 1).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j - 1, i - 1).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i - 1).B) * MF(0, 0))
End If
'point(j,i-1)*b --> MF(0,1) --> titik atas
If i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 1))
Else
Red = Red + (CInt(.GetPixel(j, i - 1).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i - 1).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i - 1).B) * MF(0, 1))
End If
'point(j+1,i-1)*c --> MF(0,2) --> titik kanan atas
If j + 1 > .Width - DY - 1 And i - 1 > 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i - 1).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j + 1, i - 1).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i - 1).B) * MF(0, 2))
End If
'point(j-1,i)*d --> MF(1,0) --> titik kiri
If j - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j - 1, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i).B) * MF(1, 0))
End If
'point(j+1,i)*f --> MF(1,2) --> titik kanan
If j + 1 > .Width - DY - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j + 1, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i).B) * MF(1, 2))
End If
'point(j-1,i+1)*g --> MF(2,0) --> titik kiri bawah
If j - 1 < 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i + 1).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j - 1, i + 1).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i + 1).B) * MF(2, 0))
End If
'point(j,i+1)*g --> MF(2,1) --> titik bawah
If i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 1))
Else
Red = Red + (CInt(.GetPixel(j, i + 1).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i + 1).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i + 1).B) * MF(2, 1))
End If
'point(j+1,i+1)*h --> MF(2,2) --> titik kanan bawah
If j + 1 > .Width - DY - 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i + 1).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j + 1, i + 1).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i + 1).B) * MF(2, 2))
End If
'normalisasi
If Red < 0 Then
Red = 0
Else
If Red > 255 Then
Red = 255
End If
End If
If Green < 0 Then
Green = 0
Else
If Green > 255 Then
Green = 255
End If
End If
If Blue < 0 Then
Blue = 0
Else
If Blue > 255 Then
Blue = 255
End If
End If
'simpan warna hasil smoothing ke point j,i
bmap.SetPixel(j, i, Color.FromArgb(Red, Green, Blue))
Next
If i Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = Int(100 * i / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * i / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Proses Smoothing Image berhasil"
End Sub
Hasil Running :
9. Weighted Smoothing
Private Sub WideSmoothingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WideSmoothingToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical +
MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
Dim MF(2, 2) As Double
'MaskFilter.Show()
'matriks Filter
' 0 1 2
'0 a b c
'1 d e f
'2 g h i
'Filter smoothing
MF(0, 0) = 1 / 16 'a
MF(0, 1) = 2 / 16 'b
MF(0, 2) = 1 / 16 'c
MF(1, 0) = 2 / 16 'd
MF(1, 1) = 4 / 16 'e
MF(1, 2) = 2 / 16 'f
MF(2, 0) = 1 / 16 'g
MF(2, 1) = 2 / 16 'h
MF(2, 2) = 1 / 16 'i
bmap = New Bitmap(picAwal.Image)
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image)
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer
Dim i As Integer, j As Integer
Dim k As Integer, l As Integer 'untuk mask border
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With bmap
For i = DX To .Height - DX - 1
For j = DY To .Width - DY - 1
'proses matriks filter
'point(j,i)*e --> titik tengah
Red = CInt(.GetPixel(j, i).R) * MF(1, 1)
Green = CInt(.GetPixel(j, i).G) * MF(1, 1)
Blue = CInt(.GetPixel(j, i).B) * MF(1, 1)
'proses titik tetangga
'point(j-1,i-1)*a--> MF(0,0)--> titik kiri atas
If j - 1 < 1 And i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i - 1).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j - 1, i - 1).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i - 1).B) * MF(0, 0))
End If
'point(j,i-1)*b --> MF(0,1) --> titik atas
If i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 1))
Else
Red = Red + (CInt(.GetPixel(j, i - 1).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i - 1).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i - 1).B) * MF(0, 1))
End If
'point(j+1,i-1)*c --> MF(0,2) --> titik kanan atas
If j + 1 > .Width - DY - 1 And i - 1 > 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i - 1).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j + 1, i - 1).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i - 1).B) * MF(0, 2))
End If
'point(j-1,i)*d --> MF(1,0) --> titik kiri
If j - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j - 1, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i).B) * MF(1, 0))
End If
'point(j+1,i)*f --> MF(1,2) --> titik kanan
If j + 1 > .Width - DY - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j + 1, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i).B) * MF(1, 2))
End If
'point(j-1,i+1)*g --> MF(2,0) --> titik kiri bawah
If j - 1 < 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i + 1).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j - 1, i + 1).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i + 1).B) * MF(2, 0))
End If
'point(j,i+1)*g --> MF(2,1) --> titik bawah
If i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 1))
Else
Red = Red + (CInt(.GetPixel(j, i + 1).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i + 1).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i + 1).B) * MF(2, 1))
End If
'point(j+1,i+1)*h --> MF(2,2) --> titik kanan bawah
If j + 1 > .Width - DY - 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i + 1).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j + 1, i + 1).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i + 1).B) * MF(2, 2))
End If
'normalisasi
If Red < 0 Then
Red = 0
Else
If Red > 255 Then
Red = 255
End If
End If
If Green < 0 Then
Green = 0
Else
If Green > 255 Then
Green = 255
End If
End If
If Blue < 0 Then
Blue = 0
Else
If Blue > 255 Then
Blue = 255
End If
End If
'simpan warna hasil smoothing ke point j,i
bmap.SetPixel(j, i, Color.FromArgb(Red, Green, Blue))
Next
If i Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = Int(100 * i / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * i / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Proses Smoothing Image berhasil"
End Sub
Hasil Running :
10. Low Pass
Private Sub LowPassToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LowPassToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical +
MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
Dim MF(2, 2) As Double
'MaskFilter.Show()
'matriks Filter
' 0 1 2
'0 a b c
'1 d e f
'2 g h i
'Filter smoothing
MF(0, 0) = 0 'a
MF(0, 1) = -1 'b
MF(0, 2) = 0 'c
MF(1, 0) = -1 'd
MF(1, 1) = 4 'e
MF(1, 2) = -1 'f
MF(2, 0) = 0 'g
MF(2, 1) = -1 'h
MF(2, 2) = 0 'i
bmap = New Bitmap(picAwal.Image)
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image)
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer
Dim i As Integer, j As Integer
Dim k As Integer, l As Integer 'untuk mask border
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With bmap
For i = DX To .Height - DX - 1
For j = DY To .Width - DY - 1
'proses matriks filter
'point(j,i)*e --> titik tengah
Red = CInt(.GetPixel(j, i).R) * MF(1, 1)
Green = CInt(.GetPixel(j, i).G) * MF(1, 1)
Blue = CInt(.GetPixel(j, i).B) * MF(1, 1)
'proses titik tetangga
'point(j-1,i-1)*a--> MF(0,0)--> titik kiri atas
If j - 1 < 1 And i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i - 1).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j - 1, i - 1).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i - 1).B) * MF(0, 0))
End If
'point(j,i-1)*b --> MF(0,1) --> titik atas
If i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 1))
Else
Red = Red + (CInt(.GetPixel(j, i - 1).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i - 1).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i - 1).B) * MF(0, 1))
End If
'point(j+1,i-1)*c --> MF(0,2) --> titik kanan atas
If j + 1 > .Width - DY - 1 And i - 1 > 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i - 1).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j + 1, i - 1).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i - 1).B) * MF(0, 2))
End If
'point(j-1,i)*d --> MF(1,0) --> titik kiri
If j - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j - 1, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i).B) * MF(1, 0))
End If
'point(j+1,i)*f --> MF(1,2) --> titik kanan
If j + 1 > .Width - DY - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j + 1, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i).B) * MF(1, 2))
End If
'point(j-1,i+1)*g --> MF(2,0) --> titik kiri bawah
If j - 1 < 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i + 1).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j - 1, i + 1).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i + 1).B) * MF(2, 0))
End If
'point(j,i+1)*g --> MF(2,1) --> titik bawah
If i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 1))
Else
Red = Red + (CInt(.GetPixel(j, i + 1).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i + 1).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i + 1).B) * MF(2, 1))
End If
'point(j+1,i+1)*h --> MF(2,2) --> titik kanan bawah
If j + 1 > .Width - DY - 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i + 1).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j + 1, i + 1).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i + 1).B) * MF(2, 2))
End If
'normalisasi
If Red < 0 Then
Red = 0
Else
If Red > 255 Then
Red = 255
End If
End If
If Green < 0 Then
Green = 0
Else
If Green > 255 Then
Green = 255
End If
End If
If Blue < 0 Then
Blue = 0
Else
If Blue > 255 Then
Blue = 255
End If
End If
'simpan warna hasil smoothing ke point j,i
bmap.SetPixel(j, i, Color.FromArgb(Red, Green, Blue))
Next
If i Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = Int(100 * i / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * i / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Proses Low Pass Image berhasil"
End Sub
Hasil Running :
11. High Pass
Private Sub HighPassToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HighPassToolStripMenuItem.Click
If PicAda = False Then
MsgBox("Pilih dulu gambar yang akan diproses", MsgBoxStyle.Critical +
MsgBoxStyle.OkOnly, "Error Proses")
Exit Sub
End If
Dim MF(2, 2) As Double
'MaskFilter.Show()
'matriks Filter
' 0 1 2
'0 a b c
'1 d e f
'2 g h i
'Filter smoothing
MF(0, 0) = -1 'a
MF(0, 1) = -1 'b
MF(0, 2) = -1 'c
MF(1, 0) = -1 'd
MF(1, 1) = 8 'e
MF(1, 2) = -1 'f
MF(2, 0) = -1 'g
MF(2, 1) = -1 'h
MF(2, 2) = -1 'i
bmap = New Bitmap(picAwal.Image)
picAwal.Image = bmap
Dim tempbmp As New Bitmap(picAwal.Image)
Dim DX As Integer = 1
Dim DY As Integer = 1
Dim Red As Integer, Green As Integer, Blue As Integer
Dim i As Integer, j As Integer
Dim k As Integer, l As Integer 'untuk mask border
ProgressBar1.Width = picAwal.Width
ProgressBar1.Show()
With bmap
For i = DX To .Height - DX - 1
For j = DY To .Width - DY - 1
'proses matriks filter
'point(j,i)*e --> titik tengah
Red = CInt(.GetPixel(j, i).R) * MF(1, 1)
Green = CInt(.GetPixel(j, i).G) * MF(1, 1)
Blue = CInt(.GetPixel(j, i).B) * MF(1, 1)
'proses titik tetangga
'point(j-1,i-1)*a--> MF(0,0)--> titik kiri atas
If j - 1 < 1 And i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i - 1).R) * MF(0, 0))
Green = Green + (CInt(.GetPixel(j - 1, i - 1).G) * MF(0, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i - 1).B) * MF(0, 0))
End If
'point(j,i-1)*b --> MF(0,1) --> titik atas
If i - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 1))
Else
Red = Red + (CInt(.GetPixel(j, i - 1).R) * MF(0, 1))
Green = Green + (CInt(.GetPixel(j, i - 1).G) * MF(0, 1))
Blue = Blue + (CInt(.GetPixel(j, i - 1).B) * MF(0, 1))
End If
'point(j+1,i-1)*c --> MF(0,2) --> titik kanan atas
If j + 1 > .Width - DY - 1 And i - 1 > 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(0, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i - 1).R) * MF(0, 2))
Green = Green + (CInt(.GetPixel(j + 1, i - 1).G) * MF(0, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i - 1).B) * MF(0, 2))
End If
'point(j-1,i)*d --> MF(1,0) --> titik kiri
If j - 1 < 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i).R) * MF(1, 0))
Green = Green + (CInt(.GetPixel(j - 1, i).G) * MF(1, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i).B) * MF(1, 0))
End If
'point(j+1,i)*f --> MF(1,2) --> titik kanan
If j + 1 > .Width - DY - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(1, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i).R) * MF(1, 2))
Green = Green + (CInt(.GetPixel(j + 1, i).G) * MF(1, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i).B) * MF(1, 2))
End If
'point(j-1,i+1)*g --> MF(2,0) --> titik kiri bawah
If j - 1 < 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 0))
Else
Red = Red + (CInt(.GetPixel(j - 1, i + 1).R) * MF(2, 0))
Green = Green + (CInt(.GetPixel(j - 1, i + 1).G) * MF(2, 0))
Blue = Blue + (CInt(.GetPixel(j - 1, i + 1).B) * MF(2, 0))
End If
'point(j,i+1)*g --> MF(2,1) --> titik bawah
If i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 1))
Else
Red = Red + (CInt(.GetPixel(j, i + 1).R) * MF(2, 1))
Green = Green + (CInt(.GetPixel(j, i + 1).G) * MF(2, 1))
Blue = Blue + (CInt(.GetPixel(j, i + 1).B) * MF(2, 1))
End If
'point(j+1,i+1)*h --> MF(2,2) --> titik kanan bawah
If j + 1 > .Width - DY - 1 And i + 1 > .Height - DX - 1 Then 'jika out of border ambil nilai tengah/point(x,y)
Red = Red + (CInt(.GetPixel(j, i).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j, i).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j, i).B) * MF(2, 2))
Else
Red = Red + (CInt(.GetPixel(j + 1, i + 1).R) * MF(2, 2))
Green = Green + (CInt(.GetPixel(j + 1, i + 1).G) * MF(2, 2))
Blue = Blue + (CInt(.GetPixel(j + 1, i + 1).B) * MF(2, 2))
End If
'normalisasi
If Red < 0 Then
Red = 0
Else
If Red > 255 Then
Red = 255
End If
End If
If Green < 0 Then
Green = 0
Else
If Green > 255 Then
Green = 255
End If
End If
If Blue < 0 Then
Blue = 0
Else
If Blue > 255 Then
Blue = 255
End If
End If
'simpan warna hasil smoothing ke point j,i
bmap.SetPixel(j, i, Color.FromArgb(Red, Green, Blue))
Next
If i Mod 10 = 0 Then
picAwal.Invalidate()
Me.Text = Int(100 * i / (picAwal.Image.Height - 2)).ToString & "%"
ProgressBar1.Value = Int(100 * i / (picAwal.Image.Height - 2))
picAwal.Refresh()
End If
Next
End With
ProgressBar1.Hide()
picAwal.Refresh()
Me.Text = "Proses High Pass Image berhasil"
End Sub
End Class
Hasil Running :