script program
Contras
xk = k x
dimana x = nilai derajat keabuan
k = nilai kontras
xk = nilai setelah pengaturan kontras
Adapun contoh praktikum sbb :
Listing program Contras sbb :
Private Sub HScroll3_Change()
bg = Val(HScroll3)
For i = 1 To Picture1.Width Step 15
For j = 1 To Picture1.Height 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)
xb1 = R * bg
xb2 = G * bg
xb3 = B * bg
Picture2.PSet (i, j), RGB(xb1, xb2, xb3)
Text3 = HScroll3.Value
Next j
Next i
End Sub
Brightness
xb = x + b
dimana x = adalah nilai derajat keabuan
b = nilai penambah
xb = hasil brightness
Adapun contoh praktikum sbb :
Listing program Brightness sebagai berikut :
Private Sub HScroll2_Change()
bg = Val(HScroll2)
For i = 1 To Picture1.Width Step 15
For j = 1 To Picture1.Height 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)
xb1 = R + bg
xb2 = G + bg
xb3 = B + bg
Picture2.PSet (i, j), RGB(xb1, xb2, xb3)
Next j
Next i
End Sub
Konversi Ke Citra Biner
Jika x<128 maka x=0, jika tidak maka x=255
Adapun contoh praktikum sebagai berikut :
Listing program diatas sebagai berikut :
Private Sub Command3_Click()
For i = 1 To Picture1.Width Step 15
For j = 1 To Picture1.Height 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)
x11 = (R + G + B) / 3
If x11 < 128 Then x11 = 0 Else x11 = 255
Picture2.PSet (i, j), RGB(x11, x11, x11)
Next j
Next i
End Sub
GrayScale
Adapun contoh praktikum sebagai berikut :
Listing program praktikum diatas :
Private Sub Command2_Click()
Dim i As Integer, j As Integer
For i = 1 To Picture1.Width Step 15
For j = 1 To Picture1.Height 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)
x12 = (R + G + B) / 3
Picture2.PSet (i, j), RGB(x12, x12, x12)
Next j
Next i
End Sub
Tresholding
Listing program praktikum diatas :
Private Sub Command5_Click()
th = Val(Text1)
For i = 1 To Picture1.Width Step 15
For j = 1 To Picture1.Height 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)
x15 = (R + G + B) / 3
a = Int(256 / th)
x15 = a * Int(x15 / a)
Picture2.PSet (i, j), RGB(x15, x15, x15)
Next j
Next i
End Sub
0 komentar:
Post a Comment