LPF
1.
Membuat form sesuai gambar dibawah ini untuk LPF :
Gambar 7.7. Form untuk LPF
2.
Mengisikan program berikut pada Tombol Low Pass Filter
:
Dim h(3, 3) As Single
Private
Sub Command1_Click()
Dim x(400, 400) As Integer
n1 = 0
For
i = 1 To Picture1.ScaleWidth Step 15
n1 = n1 + 1
n2 = 0
For j = 1 To
Picture2.ScaleHeight Step 15
warna =
Picture1.Point(i, j)
r = warna And RGB(255,
0, 0)
g = Int((warna And
RGB(0, 255, 0)) / 256)
b = Int(Int((warna And
RGB(0, 0, 255)) / 256) / 256)
n2 = n2 + 1
wx = Int((r+g+b) / 3)
x(n1, n2) = wx
Picture1.Pset (I, j),
RGB(wx, wx, wx)
Next j
Next i
For i = 1 To n1
For j = 1 To n2
z = 0
For u1 = -1 To 1
For u2 = -1 To 1
z = z + h(u1 + 2, u2 +
2) * x(i + u1, j + u2)
Next u2
Next u1
Picture2.PSet ((i – 1) *
15 + 1, (j – 1) * 15 + 1), RGB(z, z, z)
Next j
Next i
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
For i = 1 To 3
For j = 1 To 3
h(i, j) = 1 / 9
Next j
Next i
End Sub
3.
Hasil yang diperoleh :
Gambar 7.8. Hasil proses LPF
7.4.2.
HPF
1.
Membuat form sesuai gambar dibawah ini untuk HPF :
Gambar 7.9. Form untuk HPF
2.
Mengisikan program berikut pada Tombol High Pass Filter
:
Dim h(3, 3) As Single
Private
Sub Command1_Click()
Dim x(400, 400) As Integer
n1 = 0
For
i = 1 To Picture1.ScaleWidth Step 15
n1 = n1 + 1
n2 = 0
For j = 1 To
Picture2.ScaleHeight Step 15
warna =
Picture1.Point(i, j)
r = warna And RGB(255,
0, 0)
g = Int((warna And
RGB(0, 255, 0)) / 256)
b = Int(Int((warna And
RGB(0, 0, 255)) / 256) / 256)
n2 = n2 + 1
wx = Int((r+g+b) / 3)
x(n1, n2) = wx
Picture1.Pset (i, j),
RGB(wx, wx, wx)
Next j
Next i
For i = 1 To n1
For j = 1 To n2
z = 0
For u1 = -1 To 1
For u2 = -1 To 1
z = z + h(u1 + 2, u2 +
2) * x(i + u1, j + u2)
Next u2
Next u1
z = Abs(z)
Picture2.PSet ((i – 1) *
15 + 1, (j – 1) * 15 + 1), RGB(z, z, z)
Next j
Next i
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
sw = 1
For i = 1 To 3
For j = 1 To 3
If sw = 0 Then sw = 1
Else sw = 0
h(i, j) = -sw
Next j
Next i
h(2, 2) = 4
End Sub
3.
Hasil yang diperoleh :
Gambar 7.10. Hasil proses HPF
SEMOGA BERMANFAAT yaaa \(^u^)
Tidak ada komentar:
Posting Komentar