Program ini saya tujukan untuk memenuhi tugas saya
kepada Dosen Pembimbing saya.Tugas Belajar Bahasa Pemograman.
Kali ini saya mau memposting tugas kuliah saya tentang pengolahan citra.
# Listing Program Pengolahan Citra
Public Class Form2
Dim gambar2 As Bitmap
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
PictureBox2.Image
= PictureBox1.Image
End Sub
Button 1 : Button - Hijau
Private Sub button1_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles button1.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= gambar2.GetPixel(Pc, Pb).R - 10
Vh
= gambar2.GetPixel(Pc, Pb).G
Vb
= gambar2.GetPixel(Pc, Pb).B
If Vm
<= 0 Then Vm = 0
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 2 : Button + Hijau
Private Sub Button2_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button2.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= gambar2.GetPixel(Pc, Pb).R + 10
Vh
= gambar2.GetPixel(Pc, Pb).G
Vb
= gambar2.GetPixel(Pc, Pb).B
If Vm
>= 255 Then Vm = 255
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 3 : Button Greyscale
Private Sub Button3_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button3.Click
Dim Pb,
Pc As Integer
Dim Rt,
Vm, Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= gambar2.GetPixel(Pc, Pb).R
Vh
= gambar2.GetPixel(Pc, Pb).G
Vb
= gambar2.GetPixel(Pc, Pb).B
Rt
= (Vm + Vh + Vb) / 3
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Rt, Rt, Rt))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 4 : - Merah
Private Sub Button4_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button4.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= gambar2.GetPixel(Pc, Pb).R + 5
Vh
= gambar2.GetPixel(Pc, Pb).G + 5
Vb
= gambar2.GetPixel(Pc, Pb).B + 5
If Vm
>= 255 Then Vm = 255
If Vb
>= 255 Then Vb = 255
If Vh
>= 255 Then Vh = 255
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 5 : + Merah
Private Sub Button5_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button5.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= gambar2.GetPixel(Pc, Pb).R - 5
Vh
= gambar2.GetPixel(Pc, Pb).G - 5
Vb
= gambar2.GetPixel(Pc, Pb).B - 5
If Vm
<= 0 Then Vm = 0
If Vb
<= 0 Then Vb = 0
If Vh
<= 0 Then Vh = 0
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 6 : Button Rotate
Private Sub Button6_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button6.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
Dim Gambar3 As Bitmap
= New Bitmap(PictureBox1.Image)
For Pb
= gambar2.Height - 1 To 0 Step -1
For Pc
= gambar2.Width - 1 To 0 Step -1
Vm
= gambar2.GetPixel(Pc, Pb).R
Vh
= gambar2.GetPixel(Pc, Pb).G
Vb
= gambar2.GetPixel(Pc, Pb).B
Gambar3.SetPixel(gambar2.Width
- 1 - Pc, gambar2.Height - 1 - Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= Gambar3
PictureBox2.Refresh()
Next
End Sub
Button 7 : - Britness
Private Sub Button7_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button7.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= gambar2.GetPixel(Pc, Pb).R
Vh
= gambar2.GetPixel(Pc, Pb).G - 10
Vb
= gambar2.GetPixel(Pc, Pb).B
If Vh
<= 0 Then Vh = 0
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 8 : + Britness
Private Sub Button8_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button8.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= gambar2.GetPixel(Pc, Pb).R
Vh
= gambar2.GetPixel(Pc, Pb).G + 10
Vb
= gambar2.GetPixel(Pc, Pb).B
If Vh
>= 255 Then Vh = 255
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 9 : Button Negativ
Private Sub Button9_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button9.Click
Dim Pb,
Pc As Integer
Dim Vm,
Vh, Vb As Double
gambar2
= New Bitmap(PictureBox2.Image)
For Pb
= 0 To gambar2.Height - 1
For Pc
= 0 To gambar2.Width - 1
Vm
= 255 - gambar2.GetPixel(Pc, Pb).R
Vh
= 255 - gambar2.GetPixel(Pc, Pb).G
Vb
= 255 - gambar2.GetPixel(Pc, Pb).B
If Vm
<= 0 Then Vm = 0
If Vb
<= 0 Then Vb = 0
If Vh
<= 0 Then Vh = 0
gambar2.SetPixel(Pc,
Pb, Color.FromArgb(Vm, Vh, Vb))
Next
PictureBox2.Image
= gambar2
PictureBox2.Refresh()
Next
End Sub
Button 10 : Button Finish
Private Sub Button10_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles Button10.Click
End
End Sub
End Class
Dan hasil nya ada dibawah ini :
Hasil button - Hijau
Hasil Button + Hijau
Hasil Button grayscale
Hasil Button - Merah
Hasil Button + Merah
Hasil Button Rotate
Hasil Button + Brigness
Hasil Button -Brigness
Hasil Button Negatf
Terima Kasih dan Selamat mencoba ...^^
No comments:
Post a Comment