Kamis, 07 Oktober 2010

CITRA RGB HISTOGRAM


Mengambil Grafik HISTOGRAM dari CITRA WARNA

Dengan Visual Basic 6.0

    Pengolahan Citra








Buat Form seperti dia atas (Form1.frm)

    Masukkan :

PictureBox               (4x)    (dengan Name : Picture1, Picture2,Picture3,Picture4)
CommandButton     (2x)    (dengan Name : CommandButton1, CommandButton2)
Commondialog         (1x)    (dengan Name : CommonDialog1 )
[ditambahkan dari Components : "Microsoft Common Dialog Control 6.0" ]
        


BUKA Jendela "View Code"

Masukkan Code berikut :


Private Sub Command1_Click() 'Load/browse picture
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub

 
Private Sub Command2_Click() 'Histogrsm Button
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

SELESAI AND START RUN!!

KLIK "OPEN FILE GAMBAR" –pilih gambarnya- Klik "HISTOGRAM" =



THIS IS IT!



                        Ala Chief X -BDUR

Tidak ada komentar:

Posting Komentar