Kamis, 30 Juni 2011

DETEKSI TEPI MENGGUNAKAN VISUAL BASIC

• Buka terlebih dahulu visual basic Anda masing-masing kemudian buatlah sebuah form yang berisikan tool-tool berikut ini :

• Sehingga tampilan formnya

• Tuliskan source code deklarasi dan prosedur pada menu general

Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long

Dim R As Integer, G As Integer, B As Integer
Dim GradX As Long, GradY As Long, Grad As Long
Dim PixelValue As Long

Sub DecTORGB(ByVal Col As Long, R As Integer, G As Integer, B As Integer)
R = Col Mod 256
G = ((Col - R) Mod 65536) / 256
B = (Col - R - G) / 65536
If R < 0 Then R = 0: If R >= 255 Then R = 255
If G < 0 Then G = 0: If G >= 255 Then G = 255
If B < 0 Then B = 0: If B >= 255 Then B = 255
End Sub

• Berikut ini source code perintah operator Robert yang di tuliskan pada button1
Dim Op_X(-1 To 0, -1 To 0) As Integer, Op_Y(-1 To 0, -1 To 0) As Integer
Dim X As Integer, Y As Integer, I As Integer, J As Integer
Pic2.Cls
Grad = 0
Op_X(-1, -1) = 1: Op_X(0, -1) = 0
Op_X(-1, 0) = 0: Op_X(0, 0) = -1
Op_Y(-1, -1) = 0: Op_Y(0, -1) = -1
Op_Y(-1, 0) = 1: Op_Y(0, 0) = 0

For Y = 0 To Pic1.Height - 1
For X = 0 To Pic1.Width - 1
GradX = 0: GradY = 0: Grad = 0
If X = 0 Or Y = 0 Or X = Pic1.Width - 1 Or Y = Pic1.Height - 1 Then
Grad = 0
Else
For I = -1 To 0
For J = -1 To 0
PixelValue = GetPixel(Pic1.hdc, X + I, Y + J) //dapatkan pixel dari posisi x + i dan y + j
DecTORGB PixelValue, R, G, B //fungsi proses mendapatkan nilai RGB
Itensity = (R + G + B) / 3 //Itensitas / B & W
GradX = GradX + (Itensity * Op_X(I, J))
GradY = GradY + (Itensity * Op_Y(I, J))
Next J
Next I
Grad = Round(Sqr(Abs(GradX * GradX) + Abs(GradY * GradY)))
End If
If Grad <= 0 Then Grad = 0: If Grad >= 255 Then Grad = 255
SetPixel Pic2.hdc, X, Y, RGB(Grad, Grad, Grad)
Pic2.Refresh
Next X
Pic2.Refresh
Next Y

End Sub

• Contoh tampilan hasil deteksi



MASIH DALAM TAHAP PENGEMBANGAN
SEMOGA BERMANFAAT DAN SUKSES SELALU.............
BY : ARIE SUKANDAR
EMAIL : lope_arie@yahoo.co.id
website : www.ariearea89.co.cc

Brightness Dengan Visual Basic

Brightness adalah nilai kecerahan suatu pixel dalam suatu citra, yang menunjukan tingkat kecerahan dari hitam sampai putih. Tingkat kecerahan ini biasanya dinilai dari 0 (hitam) dan 255 (putih). Berikut ini saya postingkan langkah-langkah membuat aplikasi brightness dengan visual basic.
1. Buat form VB terlebih dahulu
2. Tambahkan components Microsoft windows common controls 6.0

3. Masukan tool-tool berikut ke dalam form


4. Add modules dan tuliskan source code di bawah ini di dalamnya









DAN INILAH HASIL EKSEKUSINYA.....

Jumat, 17 Juni 2011

MENAMPILKAN GAMBAR DAN HISTOGRAM DENGAN VISUAL BASIC

Tampilan Form Utama












Untuk Load Image Tampilan seperti ini.....

















Untuk Tampilan Histogram Bisa dilihat ......


Untuk Source Code nya Bisa dilihat......

Private Sub Form_Load()
Drive1.Drive = "d:\"
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()
On Error GoTo Pesan
Picture1.Picture = LoadPicture(Dir1.Path & "\" & File1.FileName)
Pesan:
If Err.Number = 481 Then
MsgBox "Nggax Bisa Di Tampilin Gambar nya", vbOKOnly, "PESAN"
End If
End Sub

Private Sub Command1_Click()
Dim hr(256) As Integer, hg(256) As Integer, hb(256) As Integer
Dim ht2 As Long
Dim xp As Integer, i As Integer, j As Integer
Dim r As Integer, g As Integer, b As Integer
Dim warna As Long, X As Long, a As Long
Picture2.Cls
Picture3.Cls
Picture4.Cls
Me.MousePointer = vbHourglass
For i = 1 To 256
hr(i) = 0
hg(i) = 0
hb(i) = 0
Next
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)
If r > 255 Then r = 255
If g > 255 Then g = 255
If b > 255 Then b = 255
hr(r) = hr(r) + 1
hg(g) = hg(g) + 1
hb(b) = hb(b) + 1
Next j
Next i
ht2 = Picture2.Height
For i = 1 To 256
xp = 15 * (i - 1) + 1
Picture2.Line (xp, ht2 - hr(i))-(xp, ht2), RGB(255, 0, 0)
Picture3.Line (xp, ht2 - hg(i))-(xp, ht2), RGB(0, 255, 0)
Picture4.Line (xp, ht2 - hb(i))-(xp, ht2), RGB(0, 0, 255)
Next i
Me.MousePointer = vbNormal
End Sub

Private Sub Command2_Click()
Unload Me
End Sub



Semoga Bermanfaat......

Kamis, 26 Mei 2011

Pengloahan Citra

PENGOLAHAN CITRA MENGGUNAKAN VISUAL BASIC 6

Tampilan form utama













coding program tersebut..... dari File - Open

Private Sub mn_open_Click()
With CommonDialog1
.Filter = "Picture Files (*.BMP; *.GIF; *.JPG)|*.BMP;*.GIF;*.JPG|Bitmap Files (*.BMP)|*.BMP|GIF Files (*.GIF)|*.GIF|JPEG Files (*.JPG)|*.JPG|All FIles (*.*)|*.*"
.DialogTitle = "Open File Gambar"
.ShowOpen
End With
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub


Eksekusi Program diatas seperti berikut.....














Untuk menampilkan Picture pilih file - open
Catatan : yang bisa dibuka BMP, GIF, JPG
















CATATAN :
Program ini Masih dalam Tahap Pengembangan Coy....