Programnya sebagai berikut :
Public Class Form1
Dim gambar1 As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox2.Image = PictureBox1.Image
End Sub
Private Sub btngrays_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngrays.Click
Dim Pb, Pc As Integer
Dim Rt, vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
Rt = (vM + vH + vb) / 3
gambar1.SetPixel(Pc, Pb, Color.FromArgb(Rt, Rt, Rt))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnmhj_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmhj.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G - 10
vb = gambar1.GetPixel(Pc, Pb).B
If vH <= 0 Then vH = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnthj_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthj.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G + 10
vb = gambar1.GetPixel(Pc, Pb).B
If vH >= 255 Then vH = 255
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnmmrh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmmrh.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R - 10
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
If vM <= 0 Then vM = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btntmrh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntmrh.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R + 10
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
If vM >= 255 Then vM = 255
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnmbrig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmbrig.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R - 5
vH = gambar1.GetPixel(Pc, Pb).G - 5
vb = gambar1.GetPixel(Pc, Pb).B - 5
If vM <= 0 Then vM = 0
If vH <= 0 Then vH = 0
If vb <= 0 Then vb = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btntbrig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntbrig.Click
Dim Pb, Pc As Integer
Dim vW, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vW = gambar1.GetPixel(Pc, Pb).R + 5
vH = gambar1.GetPixel(Pc, Pb).G + 5
vb = gambar1.GetPixel(Pc, Pb).B + 5
If vW >= 255 Then vW = 255
If vH >= 255 Then vH = 255
If vb >= 255 Then vb = 255
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vW, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnrotare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrotare.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
Dim gambar2 As Bitmap = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
gambar2.SetPixel(gambar1.Width - 1 - Pc, gambar1.Height - 1 - Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar2
PictureBox2.Refresh()
Next
End Sub
Private Sub btnnegbtnneg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnegbtnneg.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = 255 - gambar1.GetPixel(Pc, Pb).R
vH = 255 - gambar1.GetPixel(Pc, Pb).G
vb = 255 - gambar1.GetPixel(Pc, Pb).B
If vM <= 0 Then vM = 0
If vH <= 0 Then vH = 0
If vb <= 0 Then vb = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnkluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkluar.Click
End
End Sub
End Class
Dim gambar1 As Bitmap
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox2.Image = PictureBox1.Image
End Sub
Private Sub btngrays_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngrays.Click
Dim Pb, Pc As Integer
Dim Rt, vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
Rt = (vM + vH + vb) / 3
gambar1.SetPixel(Pc, Pb, Color.FromArgb(Rt, Rt, Rt))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnmhj_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmhj.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G - 10
vb = gambar1.GetPixel(Pc, Pb).B
If vH <= 0 Then vH = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnthj_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthj.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G + 10
vb = gambar1.GetPixel(Pc, Pb).B
If vH >= 255 Then vH = 255
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnmmrh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmmrh.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R - 10
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
If vM <= 0 Then vM = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btntmrh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntmrh.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R + 10
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
If vM >= 255 Then vM = 255
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnmbrig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmbrig.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R - 5
vH = gambar1.GetPixel(Pc, Pb).G - 5
vb = gambar1.GetPixel(Pc, Pb).B - 5
If vM <= 0 Then vM = 0
If vH <= 0 Then vH = 0
If vb <= 0 Then vb = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btntbrig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntbrig.Click
Dim Pb, Pc As Integer
Dim vW, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vW = gambar1.GetPixel(Pc, Pb).R + 5
vH = gambar1.GetPixel(Pc, Pb).G + 5
vb = gambar1.GetPixel(Pc, Pb).B + 5
If vW >= 255 Then vW = 255
If vH >= 255 Then vH = 255
If vb >= 255 Then vb = 255
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vW, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnrotare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrotare.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
Dim gambar2 As Bitmap = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = gambar1.GetPixel(Pc, Pb).R
vH = gambar1.GetPixel(Pc, Pb).G
vb = gambar1.GetPixel(Pc, Pb).B
gambar2.SetPixel(gambar1.Width - 1 - Pc, gambar1.Height - 1 - Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar2
PictureBox2.Refresh()
Next
End Sub
Private Sub btnnegbtnneg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnegbtnneg.Click
Dim Pb, Pc As Integer
Dim vM, vH, vb As Double
gambar1 = New Bitmap(PictureBox2.Image)
For Pb = 0 To gambar1.Height - 1
For Pc = 0 To gambar1.Width - 1
vM = 255 - gambar1.GetPixel(Pc, Pb).R
vH = 255 - gambar1.GetPixel(Pc, Pb).G
vb = 255 - gambar1.GetPixel(Pc, Pb).B
If vM <= 0 Then vM = 0
If vH <= 0 Then vH = 0
If vb <= 0 Then vb = 0
gambar1.SetPixel(Pc, Pb, Color.FromArgb(vM, vH, vb))
Next
PictureBox2.Image = gambar1
PictureBox2.Refresh()
Next
End Sub
Private Sub btnkluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkluar.Click
End
End Sub
End Class
Tekan F5 untuk menjalankannya, dan ini hasilnya...
Klik Rotare :
Klik Grayscale :
Berikut adalah pengolahan citra yang sederhana dengan menggunakan VBNet...