Perbandingan Metode K Nearest Neighbor dan K Means Clustering Dalam Segmentasi Warna Pada Citra.
Perbandingan Metode K Nearest Neighbor dan K Means Clustering dalam Segmentasi Warna pada Citra
Hanri Paskal/0322114
Jurusan Teknik Elektro, Fakultas Teknik, Universitas Kristen Maranatha Jl. Prof. Drg. Suria Sumantri 65, Bandung 40165, Indonesia
ABSTRAK
Pada Tugas Akhir ini telah dibuat program yang dapat mensegmentasikan atau memisahkan warna pada sebuah citra untuk kemudian dapat ditampilkan satu per satu. Aplikasi dari segmentasi warna dapat dimanfaatkan pada perusahaan tekstil atau percetakan untuk melakukan separasi warna. Dalam Tugas Akhir ini dua buah metoda yang digunakan untuk pensegmentasian warna pada citra yaitu K Nearest Neighbor dan K Means Clustering. Tugas Akhir ini juga membandingkan ke dua buah metoda tersebut pada lima gambar berbeda untuk disegmentasi warnanya dan diperoleh hasil bahwa secara kualitatif K Nearest Neighbor mendapat skor 3,7 (dari skala 5) dan K Means Clustering mendapat skor 3,6 (dari skala 5), hal ini menunjukan hasil segmentasi warna pada gambar secara penglihatan mata hampir tidak dapat dibedakan, sedangkan secara kuantitatif, K Means Clustering mendapat nilai persentase keberhasilan pengektrasian warna sebesar 100% sama dengan K nearest Neighbor yang juga mendapat nilai persentase keberhasilan pengekstrasian warna sebesar 100%. Jadi, dalam Tugas Akhir ini, Metoda K Nearest Neighbor lebih unggul 0,1 point dari metoda K Means Clustering, berdasarkan perbandingan secara kualitatif.
(2)
The Comparation of K Nearest Neighbor and K Means Clustering Method in Color Segmentation on Image
Hanri Paskal/0322114
Department of Electrical Engineering, Maranatha Christian University Jl. Prof. Drg. Suria Sumantri 65, Bandung 40165, Indonesia
ABSTRACT
On this Final Project has been made a program that can segmentating or separating color on image and display the result one by one. The application of color segmentation is useable on textile industries or printing industries to do the saparation of color. In this Final Project two method that used to color segmentation are K Nearest Neighbor and K Means Clustering. This Final Project is also comparing that two method on five different image to get color segmentation and the result is in qualitative scoring, K Nearest Neighbor’s score is 3.7 (from 5 scale) and K Means Clustering’s score is 3.6 (from 5 scale), it’s mean that the result of color segmentation based visuality almost not far different, but in quantitative scoring, K Means Clustering get 100% for successed in color extraction percentage and K Nearest Neighbor’s score is also 100%. So, in this Final Project K Nearest neighbor is more better 0.1 point than K Means Clustering, based qualitative scoring.
(3)
DAFTAR ISI
ABSTRAK………..……….……....i
ABSTRACT...ii
KATA PENGANTAR………...…...…….……...iii
DAFTAR ISI………...………..………..v
DAFTAR GAMBAR………....………...…...….vii
DARTAR TABEL………...…………...…..viii
BAB I PENDAHULUAN ...1
I.1 Latar Belakang ...1
I.2 Identifikasi Masalah ...1
I.3 Tujuan ...1
I.4 Pembatasan Masalah ...2
I.5 Sistematika Laporan ...2
BAB II TEORI DASAR...3
II.1 Segmentasi (Pengolahan Citra Digital)...3
II.2 Algoritma K Neares Neighbor...4
II.3 Algoritma K Means Clustering………...……….……….5
II.4 Visual Basic………...6
BAB III PERANCANGAN DAN REALISASI...7
III.1 Perancangan Antarmuka Pemakai (User Interface)…………....…………...8
III.2 Ambil Gambar………...12
III.3 Pilih Warna Otomatis………...12
III.4 Segmentasi………...……14
III.5 K Nearest Neighbor...………...16
III.6 K Means Clutering………...……..……..……….….18
III.7 Formulir Survey………..…………...22
(4)
BAB IV HASIL AKHIR………..………27
IV.1 Pengujian……...……..………..………27
IV.1.1 Pengujian Software……….………....28
IV.1.2 Survey………..………...…32
IV.1.3 Menghitung Persentase Error Jumlah Pixel Warna…………..…..34
IV.2 Analisa Data ………..………..…..35
IV.2.1 Hasil Akhir Penilaian Software...……….……36
BAB V KESIMPULAN DAN SARAN………..…………...37
V.1 Kesimpulan...37
V.2 Saran...37
DAFTAR PUSTAKA...38 LAMPIRAN A – LISTING PROGRAM
(5)
DAFTAR GAMBAR
Gambar II.1 Contoh Hasil Segmentasi Pada Citra...4
Gambar III.1 Diagram Alir Keseluruhan...7
Gambar III.2 Tampilan Program Menu Utama...8
Gambar III.3 Diagram Alir Segmentasi...15
Gambar III.4 Diagram Blok K Nearest Neighbor Dalam Pensegmentasian Warna……….16
Gambar III.5 Diagram Alir K Nearest Neighbor Dalam Pensegmentasian Warna...17
Gambar III.6 Diagram Blok K Means Clustering Dalam Pensegmentasian Warna...19
Gambar III.7 Diagram Alir K Means Clustering Dalam Pensegmentasian Warna...20
Gambar III.8 Formulir Survey...23
Gambar IV.1 Gambar Sampel Yang Digunakan...27
Gambar IV.2 Hasil Pensegmentasian Gambar 1...28
Gambar IV.3 Hasil Pensegmentasian Gambar 2...29
Gambar IV.4 Hasil Pensegmentasian Gambar 3...29
Gambar IV.5 Hasil Pensegmentasian Gambar 4...30
(6)
DAFTAR TABEL
Tabel III.1 Objek dan Properti...8
Tabel III.2 Nilai Rating Image Goodness Scale……….…24
Tabel IV.1 Hasil Jumlah Skor Survey...32
Tabel IV.2 Skor Hasil Akhir...33
Tabel IV.3 Persentase Error Jumlah Pixel Warna...34
Tabel IV.4 Rata-rata Jumlah Skor Akhir Survey...35
Tabel IV.5 Persentase Keberhasilan Pengekstrasian Warna...35
(7)
Dim bDrag As Boolean Dim ppath As String Dim centroid2 As Long
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
Private Declare Function GetTickCount& Lib "kernel32" () Option Explicit
Sub LoadPic(BackgroundPic As Control) On Error GoTo err:
With CommonDialog1
.DialogTitle = "Silahkan Pilih Gambar" .Filter = ”*.jpeg|*.*|*.gif|*.*|*.bmp|*.*" .ShowOpen
End With
BackgroundPic.Picture = LoadPicture(CommonDialog1.FileName) Arrange
Exit Sub err:
MsgBox "Error Saat Mengambil Gambar :" & CommonDialog1.FileName End Sub
Private Sub Check1_Click() If Check1.Value = 0 Then Option1.Visible = True Option2.Visible = True Option3.Visible = True Option4.Visible = True Option5.Visible = True Option6.Visible = True Option7.Visible = True Option8.Visible = True Option9.Visible = True Option10.Visible = True Option11.Visible = True Option12.Visible = True Option13.Visible = True Option14.Visible = True Option15.Visible = True Option16.Visible = True Else
(8)
Option1.Visible = False Option2.Visible = False Option3.Visible = False Option4.Visible = False Option5.Visible = False Option6.Visible = False Option7.Visible = False Option8.Visible = False Option9.Visible = False Option10.Visible = False Option11.Visible = False Option12.Visible = False Option13.Visible = False Option14.Visible = False Option15.Visible = False Option16.Visible = False End If
End Sub
Private Sub Check2_Click() If Check2.Value = 0 Then Text6.Enabled = False Option1.Visible = True Option2.Visible = True Option3.Visible = True Option4.Visible = True Option5.Visible = True Option6.Visible = True Option7.Visible = True Option8.Visible = True Option9.Visible = True Option10.Visible = True Option11.Visible = True Option12.Visible = True Option13.Visible = True Option14.Visible = True Option15.Visible = True Option16.Visible = True Else
Text6.Enabled = True Option1.Visible = False Option2.Visible = False Option3.Visible = False Option4.Visible = False Option5.Visible = False Option6.Visible = False Option7.Visible = False Option8.Visible = False Option9.Visible = False Option10.Visible = False
(9)
Option11.Visible = False Option12.Visible = False Option13.Visible = False Option14.Visible = False Option15.Visible = False Option16.Visible = False End If
End Sub
Private Sub Command1_Click() LoadPic Picture1
ppath = CommonDialog1.FileName End Sub
Private Sub Command2_Click() Dim x1 As Double
Dim y1 As Double Dim z1 As Double
If Picture1.Picture = 0 Then
MsgBox "Masukan Gambar Terlebih Dahulu!!!", vbOKOnly, "Peringatan!!!" GoTo 1
End If
If Option17 = True And Check1.Value = 0 Then
If Picture2.BackColor = &H8000000F And Picture3.BackColor = &H8000000F And Picture4.BackColor = &H8000000F And Picture5.BackColor = &H8000000F And Picture6.BackColor = &H8000000F And Picture7.BackColor = &H8000000F And Picture8.BackColor = &H8000000F And Picture9.BackColor = &H8000000F And Picture10.BackColor = &H8000000F And Picture11.BackColor = &H8000000F And Picture12.BackColor = &H8000000F And Picture13.BackColor = &H8000000F And Picture14.BackColor = &H8000000F And Picture15.BackColor = &H8000000F And Picture16.BackColor = &H8000000F Then
MsgBox "Pilih Warna Yang Akan Disegmentasi Terlebih Dahulu!!!" & vbCrLf & "(Min.1 Sampai Max.16)", vbOKOnly, "Peringatan!!!"
GoTo 1 End If
ElseIf Option17 = True And Check1.Value = 1 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9 Call warna10 Call warna11
(10)
Call warna12 Call warna13 Call warna14 Call warna15 Call warna16
ElseIf Option18 = True And Check2.Value = 0 Then
If Picture2.BackColor = &H8000000F And Picture3.BackColor = &H8000000F And Picture4.BackColor = &H8000000F And Picture5.BackColor = &H8000000F And Picture6.BackColor = &H8000000F And Picture7.BackColor = &H8000000F And Picture8.BackColor = &H8000000F And Picture9.BackColor = &H8000000F And Picture10.BackColor = &H8000000F And Picture11.BackColor = &H8000000F And Picture12.BackColor = &H8000000F And Picture13.BackColor = &H8000000F And Picture14.BackColor = &H8000000F And Picture15.BackColor = &H8000000F And Picture16.BackColor = &H8000000F Then
MsgBox "Pilih Warna Yang Akan Disegmentasi Terlebih Dahulu!!!" & vbCrLf & "(Min.1 Sampai Max.16)", vbOKOnly, "Peringatan!!!"
GoTo 1 End If
ElseIf Option18 = True And Check2.Value = 1 Then If Text6.Text = 0 Then
MsgBox "Jumlah Cluster Minimum 1 Buah!!!", vbOKOnly, "Peringatan!!!" GoTo 1
End If
If Text6.Text = 1 Then Call warna1
ElseIf Text6.Text = 2 Then Call warna1
Call warna2
ElseIf Text6.Text = 3 Then Call warna1
Call warna2 Call warna3
ElseIf Text6.Text = 4 Then Call warna1
Call warna2 Call warna3 Call warna4
ElseIf Text6.Text = 5 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5
(11)
ElseIf Text6.Text = 6 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6
ElseIf Text6.Text = 7 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7
ElseIf Text6.Text = 8 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8
ElseIf Text6.Text = 9 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9
ElseIf Text6.Text = 10 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9 Call warna10
(12)
ElseIf Text6.Text = 11 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9 Call warna10 Call warna11
ElseIf Text6.Text = 12 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9 Call warna10 Call warna11 Call warna12
ElseIf Text6.Text = 13 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9 Call warna10 Call warna11 Call warna12 Call warna13
ElseIf Text6.Text = 14 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7
(13)
Call warna8 Call warna9 Call warna10 Call warna11 Call warna12 Call warna13 Call warna14
ElseIf Text6.Text = 15 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9 Call warna10 Call warna11 Call warna12 Call warna13 Call warna14 Call warna15
ElseIf Text6.Text = 16 Then Call warna1
Call warna2 Call warna3 Call warna4 Call warna5 Call warna6 Call warna7 Call warna8 Call warna9 Call warna10 Call warna11 Call warna12 Call warna13 Call warna14 Call warna15 Call warna16 Else
MsgBox "Jumlah Cluster Maksimum 16 Buah!!!", vbOKOnly, "Peringatan!!!" GoTo 1
End If Else
MsgBox "Tentukan Algoritma Terlebih Dahulu!!!", vbOKOnly, "Peringatan!!!" GoTo 1
(14)
End If
x1 = GetTickCount& If Option17 = True Then Call k_nearest
End If
If Option18 = True Then Call k_means
End If
Image1.Picture = Picture18.Image Label1.Visible = True
Text1.Text = 1
y1 = GetTickCount& z1 = y1 - x1
Label3.Visible = False Label4.Visible = False Label5.Visible = False Label6.Visible = False Label7.Visible = False Label8.Visible = False Label9.Visible = False Label10.Visible = False Label11.Visible = False Label12.Visible = False Label13.Visible = False Label14.Visible = False Label15.Visible = False Label16.Visible = False Label17.Visible = False Text3.Text = 0
Text4.Text = 0 Text5.Text = 0
MsgBox "Dengan Waktu : " & Format(z1 / 1000, "####.##") & " Detik", vbOKOnly, "Sukses!!!"
1: End Sub
Private Sub Command3_Click() If Image1.Picture = 0 Then
MsgBox "Tidak Ada Gambar Untuk Disimpan!!!", vbOKOnly, "Peringatan!!!" GoTo 1
(15)
SavePicture Image1.Picture, Left(ppath, Len(ppath) - 4) & ".bmp"
MsgBox "Gambar Disimpan Pada: " & Left(ppath, Len(ppath) - 4) & ".bmp" 1:
End Sub
Private Sub Command4_Click() End
End Sub
Private Sub Command5_Click()
MsgBox "Karya Tugas Akhir - Segmentasi Warna" & vbCrLf & vbCrLf & "Hanri Paskal" & vbCrLf & "0322114" & vbCrLf & "Jurusan Teknik Elektro, Fakutas Teknik" & vbCrLf & "Universitas Kristen Maranatha" & vbCrLf & "Bandung" & vbCrLf & "2008" & vbCrLf & vbCrLf & "[email protected]", vbOKOnly, "Data Diri"
End Sub
Private Sub Command6_Click() If Image1.Picture = 0 Then
MsgBox "Belum Ada Gambar Yang Disegmentasi!!!", vbOKOnly, "Peringatan!!!" GoTo 2
End If
Text1.Text = Text1.Text + 1 1:
If Text1.Text = 1 Then Label1.Visible = True
Image1.Picture = Picture18.Image ElseIf Text1.Text = 2 Then
Label1.Visible = False
Image1.Picture = Picture19.Image Label3.Visible = True
ElseIf Text1.Text = 3 Then Label3.Visible = False
Image1.Picture = Picture20.Image Label4.Visible = True
ElseIf Text1.Text = 4 Then Label4.Visible = False
Image1.Picture = Picture21.Image Label5.Visible = True
ElseIf Text1.Text = 5 Then Label5.Visible = False
Image1.Picture = Picture22.Image Label6.Visible = True
(16)
Label6.Visible = False
Image1.Picture = Picture23.Image Label7.Visible = True
ElseIf Text1.Text = 7 Then Label7.Visible = False
Image1.Picture = Picture24.Image Label8.Visible = True
ElseIf Text1.Text = 8 Then Label8.Visible = False
Image1.Picture = Picture25.Image Label9.Visible = True
ElseIf Text1.Text = 9 Then Label9.Visible = False
Image1.Picture = Picture26.Image Label10.Visible = True
ElseIf Text1.Text = 10 Then Label10.Visible = False
Image1.Picture = Picture27.Image Label11.Visible = True
ElseIf Text1.Text = 11 Then Label11.Visible = False
Image1.Picture = Picture28.Image Label12.Visible = True
ElseIf Text1.Text = 12 Then Label12.Visible = False
Image1.Picture = Picture29.Image Label13.Visible = True
ElseIf Text1.Text = 13 Then Label13.Visible = False
Image1.Picture = Picture30.Image Label14.Visible = True
ElseIf Text1.Text = 14 Then Label14.Visible = False
Image1.Picture = Picture31.Image Label15.Visible = True
ElseIf Text1.Text = 15 Then Label15.Visible = False
Image1.Picture = Picture32.Image Label16.Visible = True
ElseIf Text1.Text = 16 Then Label16.Visible = False
Image1.Picture = Picture33.Image Label17.Visible = True
Else
Label17.Visible = False Text1.Text = 1
GoTo 1 End If
(17)
Text4.Text = 0 Text5.Text = 0 2:
End Sub
Private Sub Command7_Click() If Image1.Picture = 0 Then
MsgBox "Belum Ada Gambar Yang Disegmentasi!!!", vbOKOnly, "Peringatan!!!" GoTo 1
End If
Text1.Text = Text1.Text - 1 2:
If Text1.Text = 16 Then Label16.Visible = False
Image1.Picture = Picture33.Image Label17.Visible = True
ElseIf Text1.Text = 15 Then Label17.Visible = False
Image1.Picture = Picture32.Image Label16.Visible = True
ElseIf Text1.Text = 14 Then Label16.Visible = False
Image1.Picture = Picture31.Image Label15.Visible = True
ElseIf Text1.Text = 13 Then Label15.Visible = False
Image1.Picture = Picture30.Image Label14.Visible = True
ElseIf Text1.Text = 12 Then Label14.Visible = False
Image1.Picture = Picture29.Image Label13.Visible = True
ElseIf Text1.Text = 11 Then Label13.Visible = False
Image1.Picture = Picture28.Image Label12.Visible = True
ElseIf Text1.Text = 10 Then Label12.Visible = False
Image1.Picture = Picture27.Image Label11.Visible = True
ElseIf Text1.Text = 9 Then Label11.Visible = False
Image1.Picture = Picture26.Image Label10.Visible = True
ElseIf Text1.Text = 8 Then Label10.Visible = False
(18)
Label9.Visible = True ElseIf Text1.Text = 7 Then Label9.Visible = False
Image1.Picture = Picture24.Image Label8.Visible = True
ElseIf Text1.Text = 6 Then Label8.Visible = False
Image1.Picture = Picture23.Image Label7.Visible = True
ElseIf Text1.Text = 5 Then Label7.Visible = False
Image1.Picture = Picture22.Image Label6.Visible = True
ElseIf Text1.Text = 4 Then Label6.Visible = False
Image1.Picture = Picture21.Image Label5.Visible = True
ElseIf Text1.Text = 3 Then Label5.Visible = False
Image1.Picture = Picture20.Image Label4.Visible = True
ElseIf Text1.Text = 2 Then Label4.Visible = False
Image1.Picture = Picture19.Image Label3.Visible = True
ElseIf Text1.Text = 1 Then Label3.Visible = False
Image1.Picture = Picture18.Image Label1.Visible = True
Else
Label1.Visible = False Text1.Text = 16 GoTo 2
End If
Text3.Text = 0 Text4.Text = 0 Text5.Text = 0 1:
End Sub
Private Sub Command9_Click() Picture2.BackColor = &H8000000F Picture3.BackColor = &H8000000F Picture4.BackColor = &H8000000F Picture5.BackColor = &H8000000F Picture6.BackColor = &H8000000F Picture7.BackColor = &H8000000F Picture8.BackColor = &H8000000F
(19)
Picture9.BackColor = &H8000000F Picture10.BackColor = &H8000000F Picture11.BackColor = &H8000000F Picture12.BackColor = &H8000000F Picture13.BackColor = &H8000000F Picture14.BackColor = &H8000000F Picture15.BackColor = &H8000000F Picture16.BackColor = &H8000000F Picture17.BackColor = &H8000000F Text2.Text = 0
End Sub
Private Sub Form_Load() Arrange
Label20.Visible = False Text6.Visible = False Text6.Enabled = False End Sub
Sub Arrange()
Picture18.Move Picture1.Left + Picture1.Width + 20, Picture1.Top, Picture1.Width, Picture1.Height
Picture19.Move Picture18.Left + Picture18.Width + 20, Picture18.Top, Picture1.Width, Picture1.Height
Picture20.Move Picture19.Left + Picture19.Width + 20, Picture19.Top, Picture1.Width, Picture1.Height
Picture21.Move Picture20.Left + Picture20.Width + 20, Picture20.Top, Picture1.Width, Picture1.Height
Picture22.Move Picture21.Left + Picture21.Width + 20, Picture21.Top, Picture1.Width, Picture1.Height
Picture23.Move Picture22.Left + Picture22.Width + 20, Picture22.Top, Picture1.Width, Picture1.Height
Picture24.Move Picture23.Left + Picture23.Width + 20, Picture23.Top, Picture1.Width, Picture1.Height
Picture25.Move Picture24.Left + Picture24.Width + 20, Picture24.Top, Picture1.Width, Picture1.Height
Picture26.Move Picture25.Left + Picture25.Width + 20, Picture25.Top, Picture1.Width, Picture1.Height
Picture27.Move Picture26.Left + Picture26.Width + 20, Picture26.Top, Picture1.Width, Picture1.Height
Picture28.Move Picture27.Left + Picture27.Width + 20, Picture27.Top, Picture1.Width, Picture1.Height
Picture29.Move Picture28.Left + Picture28.Width + 20, Picture28.Top, Picture1.Width, Picture1.Height
Picture30.Move Picture29.Left + Picture29.Width + 20, Picture29.Top, Picture1.Width, Picture1.Height
Picture31.Move Picture30.Left + Picture30.Width + 20, Picture30.Top, Picture1.Width, Picture1.Height
(20)
Picture32.Move Picture31.Left + Picture31.Width + 20, Picture31.Top, Picture1.Width, Picture1.Height
Picture33.Move Picture32.Left + Picture32.Width + 20, Picture32.Top, Picture1.Width, Picture1.Height
End Sub
Private Sub Option17_Click() Label20.Visible = False Text6.Visible = False Text6.Enabled = False Check1.Visible = True Check2.Visible = False Label21.Visible = True Option1.Visible = True Option2.Visible = True Option3.Visible = True Option4.Visible = True Option5.Visible = True Option6.Visible = True Option7.Visible = True Option8.Visible = True Option9.Visible = True Option10.Visible = True Option11.Visible = True Option12.Visible = True Option13.Visible = True Option14.Visible = True Option15.Visible = True Option16.Visible = True
If Option17 = True And Check1.Value = 1 Then Option1.Visible = False
Option2.Visible = False Option3.Visible = False Option4.Visible = False Option5.Visible = False Option6.Visible = False Option7.Visible = False Option8.Visible = False Option9.Visible = False Option10.Visible = False Option11.Visible = False Option12.Visible = False Option13.Visible = False Option14.Visible = False Option15.Visible = False Option16.Visible = False End If
(21)
End Sub
Private Sub Option18_Click() Label20.Visible = True Text6.Visible = True Text6.Enabled = False Check2.Visible = True Check1.Visible = False Label21.Visible = False Option1.Visible = True Option2.Visible = True Option3.Visible = True Option4.Visible = True Option5.Visible = True Option6.Visible = True Option7.Visible = True Option8.Visible = True Option9.Visible = True Option10.Visible = True Option11.Visible = True Option12.Visible = True Option13.Visible = True Option14.Visible = True Option15.Visible = True Option16.Visible = True
If Option18 = True And Check2.Value = 1 Then Option1.Visible = False
Option2.Visible = False Option3.Visible = False Option4.Visible = False Option5.Visible = False Option6.Visible = False Option7.Visible = False Option8.Visible = False Option9.Visible = False Option10.Visible = False Option11.Visible = False Option12.Visible = False Option13.Visible = False Option14.Visible = False Option15.Visible = False Option16.Visible = False End If
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
(22)
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error Resume Next If Option1 = True Then
If bDrag Then Picture2.BackColor = Picture1.Point(x, y) End If
If Option2 = True Then
If bDrag Then Picture3.BackColor = Picture1.Point(x, y) End If
If Option3 = True Then
If bDrag Then Picture4.BackColor = Picture1.Point(x, y) End If
If Option4 = True Then
If bDrag Then Picture5.BackColor = Picture1.Point(x, y) End If
If Option5 = True Then
If bDrag Then Picture6.BackColor = Picture1.Point(x, y) End If
If Option6 = True Then
If bDrag Then Picture7.BackColor = Picture1.Point(x, y) End If
If Option7 = True Then
If bDrag Then Picture8.BackColor = Picture1.Point(x, y) End If
If Option8 = True Then
If bDrag Then Picture9.BackColor = Picture1.Point(x, y) End If
If Option9 = True Then
If bDrag Then Picture10.BackColor = Picture1.Point(x, y) End If
If Option10 = True Then
If bDrag Then Picture11.BackColor = Picture1.Point(x, y) End If
If Option11 = True Then
If bDrag Then Picture12.BackColor = Picture1.Point(x, y) End If
If Option12 = True Then
If bDrag Then Picture13.BackColor = Picture1.Point(x, y) End If
If Option13 = True Then
If bDrag Then Picture14.BackColor = Picture1.Point(x, y) End If
If Option14 = True Then
If bDrag Then Picture15.BackColor = Picture1.Point(x, y) End If
If Option15 = True Then
(23)
End If
If Option16 = True Then
If bDrag Then Picture17.BackColor = Picture1.Point(x, y) End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
bDrag = False End Sub
Private Sub warna1()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture2.BackColor = warna And RGB(R, G, B)
If Picture2.BackColor <> &H8000000F Then GoTo 1
End If Next j Next i 1: End Sub
Private Sub warna2()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 To Picture1.Height Step 15
warna = Picture1.Point(i, j)
(24)
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) Picture3.BackColor = warna And RGB(R, G, B)
If Picture3.BackColor <> Picture2.BackColor Then GoTo 1
End If Next j Next i 1: End Sub
Private Sub warna3()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture4.BackColor = warna And RGB(R, G, B)
If Picture4.BackColor <> Picture2.BackColor And Picture4.BackColor <> Picture3.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna4()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
(25)
For j = 0 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) Picture5.BackColor = warna And RGB(R, G, B)
If Picture5.BackColor <> Picture2.BackColor And Picture5.BackColor <> Picture3.BackColor And Picture5.BackColor <> Picture4.BackColor Then GoTo 1
End If Next j Next i 1: End Sub
Private Sub warna5()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture6.BackColor = warna And RGB(R, G, B)
If Picture6.BackColor <> Picture2.BackColor And Picture6.BackColor <> Picture3.BackColor And Picture6.BackColor <> Picture4.BackColor And Picture6.BackColor <> Picture5.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna6()
(26)
Dim warna As String Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture7.BackColor = warna And RGB(R, G, B)
If Picture7.BackColor <> Picture2.BackColor And Picture7.BackColor <> Picture3.BackColor And Picture7.BackColor <> Picture4.BackColor And Picture7.BackColor <> Picture5.BackColor And Picture7.BackColor <> Picture6.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna7()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture8.BackColor = warna And RGB(R, G, B)
If Picture8.BackColor <> Picture2.BackColor And Picture8.BackColor <> Picture3.BackColor And Picture8.BackColor <> Picture4.BackColor And Picture8.BackColor <> Picture5.BackColor And Picture8.BackColor <> Picture6.BackColor And Picture8.BackColor <> Picture7.BackColor Then GoTo 1
(27)
End If Next j Next i 1: End Sub
Private Sub warna8()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture9.BackColor = warna And RGB(R, G, B)
If Picture9.BackColor <> Picture2.BackColor And Picture9.BackColor <> Picture3.BackColor And Picture9.BackColor <> Picture4.BackColor And Picture9.BackColor <> Picture5.BackColor And Picture9.BackColor <> Picture6.BackColor And Picture9.BackColor <> Picture7.BackColor And Picture9.BackColor <> Picture8.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna9()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 To Picture1.Height Step 15
(28)
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) Picture10.BackColor = warna And RGB(R, G, B)
If Picture10.BackColor <> Picture2.BackColor And Picture10.BackColor <> Picture3.BackColor And Picture10.BackColor <> Picture4.BackColor And Picture10.BackColor <> Picture5.BackColor And Picture10.BackColor <> Picture6.BackColor And Picture10.BackColor <> Picture7.BackColor And Picture10.BackColor <> Picture8.BackColor And Picture10.BackColor <> Picture9.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna10()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture11.BackColor = warna And RGB(R, G, B)
If Picture11.BackColor <> Picture2.BackColor And Picture11.BackColor <> Picture3.BackColor And Picture11.BackColor <> Picture4.BackColor And Picture11.BackColor <> Picture5.BackColor And Picture11.BackColor <> Picture6.BackColor And Picture11.BackColor <> Picture7.BackColor And Picture11.BackColor <> Picture8.BackColor And Picture11.BackColor <> Picture9.BackColor And Picture11.BackColor <> Picture10.BackColor Then GoTo 1
End If Next j Next i
(29)
1: End Sub
Private Sub warna11()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture12.BackColor = warna And RGB(R, G, B)
If Picture12.BackColor <> Picture2.BackColor And Picture12.BackColor <> Picture3.BackColor And Picture12.BackColor <> Picture4.BackColor And Picture12.BackColor <> Picture5.BackColor And Picture12.BackColor <> Picture6.BackColor And Picture12.BackColor <> Picture7.BackColor And Picture12.BackColor <> Picture8.BackColor And Picture12.BackColor <> Picture9.BackColor And Picture12.BackColor <> Picture10.BackColor And Picture12.BackColor <> Picture11.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna12()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 To Picture1.Height Step 15
warna = Picture1.Point(i, j)
R = warna And RGB(255, 0, 0)
(30)
B = Int(Int(warna And RGB(0, 0, 255) / 256) / 256) Picture13.BackColor = warna And RGB(R, G, B)
If Picture13.BackColor <> Picture2.BackColor And Picture13.BackColor <> Picture3.BackColor And Picture13.BackColor <> Picture4.BackColor And Picture13.BackColor <> Picture5.BackColor And Picture13.BackColor <> Picture6.BackColor And Picture13.BackColor <> Picture7.BackColor And Picture13.BackColor <> Picture8.BackColor And Picture13.BackColor <> Picture9.BackColor And Picture13.BackColor <> Picture10.BackColor And Picture13.BackColor <> Picture11.BackColor And Picture13.BackColor <> Picture12.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna13()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture14.BackColor = warna And RGB(R, G, B)
If Picture14.BackColor <> Picture2.BackColor And Picture14.BackColor <> Picture3.BackColor And Picture14.BackColor <> Picture4.BackColor And Picture14.BackColor <> Picture5.BackColor And Picture14.BackColor <> Picture6.BackColor And Picture14.BackColor <> Picture7.BackColor And Picture14.BackColor <> Picture8.BackColor And Picture14.BackColor <> Picture9.BackColor And Picture14.BackColor <> Picture10.BackColor And Picture14.BackColor <> Picture11.BackColor And Picture14.BackColor <> Picture12.BackColor And Picture14.BackColor <> Picture13.BackColor Then GoTo 1
End If Next j
(31)
Next i 1: End Sub
Private Sub warna14()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture15.BackColor = warna And RGB(R, G, B)
If Picture15.BackColor <> Picture2.BackColor And Picture15.BackColor <> Picture3.BackColor And Picture15.BackColor <> Picture4.BackColor And Picture15.BackColor <> Picture5.BackColor And Picture15.BackColor <> Picture6.BackColor And Picture15.BackColor <> Picture7.BackColor And Picture15.BackColor <> Picture8.BackColor And Picture15.BackColor <> Picture9.BackColor And Picture15.BackColor <> Picture10.BackColor And Picture15.BackColor <> Picture11.BackColor And Picture15.BackColor <> Picture12.BackColor And Picture15.BackColor <> Picture13.BackColor And Picture15.BackColor <> Picture14.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna15()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 To Picture1.Height Step 15
(32)
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) Picture16.BackColor = warna And RGB(R, G, B)
If Picture16.BackColor <> Picture2.BackColor And Picture16.BackColor <> Picture3.BackColor And Picture16.BackColor <> Picture4.BackColor And Picture16.BackColor <> Picture5.BackColor And Picture16.BackColor <> Picture6.BackColor And Picture16.BackColor <> Picture7.BackColor And Picture16.BackColor <> Picture8.BackColor And Picture16.BackColor <> Picture9.BackColor And Picture16.BackColor <> Picture10.BackColor And Picture16.BackColor <> Picture11.BackColor And Picture16.BackColor <> Picture12.BackColor And Picture16.BackColor <> Picture13.BackColor And Picture16.BackColor <> Picture14.BackColor And Picture16.BackColor <> Picture15.BackColor Then
GoTo 1 End If Next j Next i 1: End Sub
Private Sub warna16()
Dim i As Integer, j As Integer Dim warna As String
Dim R As Integer Dim G As Integer Dim B As Integer
For i = 0 To Picture1.Width Step 15 For j = 0 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) Picture17.BackColor = warna And RGB(R, G, B)
If Picture17.BackColor <> Picture2.BackColor And Picture17.BackColor <> Picture3.BackColor And Picture17.BackColor <> Picture4.BackColor And Picture17.BackColor <> Picture5.BackColor And Picture17.BackColor <> Picture6.BackColor And Picture17.BackColor <> Picture7.BackColor And Picture17.BackColor <> Picture8.BackColor And Picture17.BackColor <> Picture9.BackColor And Picture17.BackColor <> Picture10.BackColor And Picture17.BackColor <> Picture11.BackColor And Picture17.BackColor <> Picture12.BackColor And Picture17.BackColor <> Picture13.BackColor And
(33)
Picture17.BackColor <> Picture14.BackColor And Picture17.BackColor <> Picture15.BackColor And Picture17.BackColor <> Picture16.BackColor Then GoTo 1
End If Next j Next i 1: End Sub
Private Sub Command8_Click() Dim x1 As Double
Dim y1 As Double Dim z1 As Double
If Picture1.Picture = 0 Then
MsgBox "Tidak Ada Gambar Untuk Dihitung!!!", vbOKOnly, "Peringatan!!!" GoTo 1
End If
If Text1.Text = 0 Then
MsgBox "Tidak Ada Gambar Untuk Dibandingkan!!!", vbOKOnly, "Peringatan!!!" GoTo 1
End If
x1 = GetTickCount& If Text1.Text = 1 Then Call Hitung1
ElseIf Text1.Text = 2 Then Call Hitung2
ElseIf Text1.Text = 3 Then Call Hitung3
ElseIf Text1.Text = 4 Then Call Hitung4
ElseIf Text1.Text = 5 Then Call Hitung5
ElseIf Text1.Text = 6 Then Call Hitung6
ElseIf Text1.Text = 7 Then Call Hitung7
ElseIf Text1.Text = 8 Then Call Hitung8
ElseIf Text1.Text = 9 Then Call Hitung9
ElseIf Text1.Text = 10 Then Call Hitung10
ElseIf Text1.Text = 11 Then Call Hitung11
(34)
Call Hitung12
ElseIf Text1.Text = 13 Then Call Hitung13
ElseIf Text1.Text = 14 Then Call Hitung14
ElseIf Text1.Text = 15 Then Call Hitung15
ElseIf Text1.Text = 16 Then Call Hitung16
End If
y1 = GetTickCount& z1 = y1 - x1
MsgBox "Dengan Waktu : " & Format(z1 / 1000, "####.##") & " Detik", vbOKOnly, "Sukses!!!"
1: End Sub
Private Sub Hitung1a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture2.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung1b() Dim i As Integer Dim j As Integer
(35)
Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture18.Width Step 15 For j = 1 To Picture18.Height Step 15
warna = Picture18.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture2.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung1() Call Hitung1a
Call Hitung1b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung2a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture1.Width Step 15 For j = 1 To Picture1.Height Step 15
warna = Picture1.Point(i, j)
(36)
G = Int((warna And RGB(0, 255, 0)) / 256)
B = Int(Int((warna And RGB(0, 0, 255)) / 256) / 256)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture3.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung2b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture19.Width Step 15 For j = 1 To Picture19.Height Step 15
warna = Picture19.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture3.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung2() Call Hitung2a
Call Hitung2b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
(37)
Private Sub Hitung3a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture4.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung3b() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture20.Width Step 15 For j = 1 To Picture20.Height Step 15
warna = Picture20.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)
(38)
If Picture34.BackColor = Picture4.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung3() Call Hitung3a
Call Hitung3b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung4a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture5.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung4b() Dim i As Integer
(39)
Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture21.Width Step 15 For j = 1 To Picture21.Height Step 15
warna = Picture21.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture5.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung4() Call Hitung4a
Call Hitung4b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung5a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture1.Width Step 15 For j = 1 To Picture1.Height Step 15
warna = Picture1.Point(i, j)
(40)
G = Int((warna And RGB(0, 255, 0)) / 256)
B = Int(Int((warna And RGB(0, 0, 255)) / 256) / 256)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture6.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung5b() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture22.Width Step 15 For j = 1 To Picture22.Height Step 15
warna = Picture22.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture6.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung5() Call Hitung5a
Call Hitung5b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
(41)
Private Sub Hitung6a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture7.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung6b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture23.Width Step 15 For j = 1 To Picture23.Height Step 15
warna = Picture23.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)
(42)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture7.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung6() Call Hitung6a
Call Hitung6b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung7a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture8.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung7b() Dim i As Integer
(43)
Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture24.Width Step 15 For j = 1 To Picture24.Height Step 15
warna = Picture24.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture8.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung7() Call Hitung7a
Call Hitung7b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung8a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture1.Width Step 15 For j = 1 To Picture1.Height Step 15
warna = Picture1.Point(i, j)
(44)
G = Int((warna And RGB(0, 255, 0)) / 256)
B = Int(Int((warna And RGB(0, 0, 255)) / 256) / 256)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture9.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung8b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture25.Width Step 15 For j = 1 To Picture25.Height Step 15
warna = Picture25.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture9.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung8() Call Hitung8a
Call Hitung8b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
(45)
Private Sub Hitung9a() Dim i As Integer Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture10.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung9b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture26.Width Step 15 For j = 1 To Picture26.Height Step 15
warna = Picture26.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)
(46)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture10.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung9() Call Hitung9a
Call Hitung9b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung10a() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture11.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung10b() Dim i As Integer
(47)
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture27.Width Step 15 For j = 1 To Picture27.Height Step 15
warna = Picture27.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture11.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung10() Call Hitung10a
Call Hitung10b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung11a() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture1.Width Step 15 For j = 1 To Picture1.Height Step 15
warna = Picture1.Point(i, j)
(48)
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture12.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung11b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture28.Width Step 15 For j = 1 To Picture28.Height Step 15
warna = Picture28.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture12.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung11() Call Hitung11a
Call Hitung11b
(49)
End Sub
Private Sub Hitung12a() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture13.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung12b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture29.Width Step 15 For j = 1 To Picture29.Height Step 15
warna = Picture29.Point(i, j)
R = warna And RGB(255, 0, 0)
G = Int((warna And RGB(0, 255, 0)) / 256)
(50)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture13.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung12() Call Hitung12a
Call Hitung12b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung13a() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture14.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung13b() Dim i As Integer
(51)
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture30.Width Step 15 For j = 1 To Picture30.Height Step 15
warna = Picture30.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture14.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung13() Call Hitung13a
Call Hitung13b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung14a() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture1.Width Step 15 For j = 1 To Picture1.Height Step 15
warna = Picture1.Point(i, j)
(52)
G = Int((warna And RGB(0, 255, 0)) / 256)
B = Int(Int((warna And RGB(0, 0, 255)) / 256) / 256)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture15.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung14b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture31.Width Step 15 For j = 1 To Picture31.Height Step 15
warna = Picture31.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture15.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung14() Call Hitung14a
Call Hitung14b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
(53)
Private Sub Hitung15a() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture16.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung15b() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture32.Width Step 15 For j = 1 To Picture32.Height Step 15
warna = Picture32.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)
(54)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture16.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung15() Call Hitung15a
Call Hitung15b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub Hitung16a() Dim i As Integer
Dim j As Integer Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture17.BackColor Then x = x + 1
Text3.Text = x End If
Next j Next i End Sub
Private Sub Hitung16b() Dim i As Integer
(55)
Dim x As Long Dim y As Integer Dim z As Integer Dim R As Integer Dim G As Integer Dim B As Integer Dim warna As String
For i = 1 To Picture33.Width Step 15 For j = 1 To Picture33.Height Step 15
warna = Picture33.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)
Picture34.BackColor = warna And RGB(R, G, B) If Picture34.BackColor = Picture17.BackColor Then x = x + 1
Text4.Text = x End If
Next j Next i End Sub
Private Sub Hitung16() Call Hitung16a
Call Hitung16b
Text5.Text = ((Abs(Text3 - Text4)) / Text3) * 100 End Sub
Private Sub k_nearest() Dim i As Integer, j As Integer
Dim R As Integer, G As Integer, B As Integer Dim R2 As Integer, G2 As Integer, B2 As Integer Dim c As Long, c2 As Long
Dim t As Integer t = 30
ProgressBar1.Value = 0
If Picture2.BackColor <> &H8000000F Then Text2.Text = 1
Picture18.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
(56)
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture2.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture18.hdc, i, j, Picture2.BackColor
Else
SetPixel Picture18.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 6.25
If Picture3.BackColor <> &H8000000F Then Text2.Text = 2
Picture19.Cls
Picture19.DrawWidth = 1
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture3.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture19.hdc, i, j, Picture3.BackColor
Else
SetPixel Picture19.hdc, i, j, vbBlack End If
(57)
Next j Next i End If
ProgressBar1.Value = 12.5
If Picture4.BackColor <> &H8000000F Then Text2.Text = 3
Picture20.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture4.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then
SetPixel Picture20.hdc, i, j, Picture4.BackColor
Else
SetPixel Picture20.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 18.75
If Picture5.BackColor <> &H8000000F Then Text2.Text = 4
Picture21.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
(58)
B = (c \ 256 \ 256) Mod 256
c2 = Picture5.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture21.hdc, i, j, Picture5.BackColor
Else
SetPixel Picture21.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 25
If Picture6.BackColor <> &H8000000F Then Text2.Text = 5
Picture22.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture6.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture22.hdc, i, j, Picture6.BackColor
Else
SetPixel Picture22.hdc, i, j, vbBlack End If
Next j
(59)
Next i End If
ProgressBar1.Value = 31.25
If Picture7.BackColor <> &H8000000F Then Text2.Text = 6
Picture23.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture7.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture23.hdc, i, j, Picture7.BackColor
Else
SetPixel Picture23.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 37.5
If Picture8.BackColor <> &H8000000F Then Text2.Text = 7
Picture24.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
(60)
c2 = Picture8.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture24.hdc, i, j, Picture8.BackColor
Else
SetPixel Picture24.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 43.75
If Picture9.BackColor <> &H8000000F Then Text2.Text = 8
Picture25.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture9.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture25.hdc, i, j, Picture9.BackColor
Else
SetPixel Picture25.hdc, i, j, vbBlack End If
Next j
(61)
Next i End If
ProgressBar1.Value = 50
If Picture10.BackColor <> &H8000000F Then Text2.Text = 9
Picture26.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture10.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture26.hdc, i, j, Picture10.BackColor
Else
SetPixel Picture26.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 56.25
If Picture11.BackColor <> &H8000000F Then Text2.Text = 10
Picture27.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
(62)
c2 = Picture11.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture27.hdc, i, j, Picture11.BackColor
Else
SetPixel Picture27.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 62.5
If Picture12.BackColor <> &H8000000F Then Text2.Text = 11
Picture28.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture12.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture28.hdc, i, j, Picture12.BackColor
Else
SetPixel Picture28.hdc, i, j, vbBlack End If
Next j Next i
(63)
End If
ProgressBar1.Value = 68.75
If Picture13.BackColor <> &H8000000F Then Text2.Text = 12
Picture29.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture13.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture29.hdc, i, j, Picture13.BackColor
Else
SetPixel Picture29.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 75
If Picture14.BackColor <> &H8000000F Then Text2.Text = 13
Picture30.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
(64)
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture30.hdc, i, j, Picture14.BackColor
Else
SetPixel Picture30.hdc, i, j, vbBlack End If
Next j Next i End If
ProgressBar1.Value = 81.25
If Picture15.BackColor <> &H8000000F Then Text2.Text = 14
Picture31.Cls
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight
c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
c2 = Picture15.BackColor
R2 = c2 Mod 256
G2 = (c2 \ 256) Mod 256 B2 = (c2 \ 256 \ 256) Mod 256
If Abs(R - R2) < t And Abs(G - G2) < t And Abs(B - B2) < t Then SetPixel Picture31.hdc, i, j, Picture15.BackColor
Else
SetPixel Picture31.hdc, i, j, vbBlack End If
Next j Next i End If
(1)
A-88 For i = 1 To Picture33.Width Step 15 For j = 1 To Picture33.Height Step 15
warna = Picture33.Point(i, j)
R3 = warna Mod 256
G3 = (warna \ 256) Mod 256 B3 = (warna \ 256 \ 256) Mod 256
If Abs(R3 - R2) < euc And Abs(G3 - G2) < euc And Abs(B3 - B2) < euc Then x = x + warna
y = y + 1 If y >= 2 Then z = x / 2 x = z End If centroid2 = z
R4 = centroid2 Mod 256
G4 = (centroid2 \ 256) Mod 256 B4 = (centroid2 \ 256 \ 256) Mod 256
If Abs(R4 - R2) >= euc2 And Abs(G4 - G2) >= euc2 And Abs(B4 - B2) >= euc2 Then
centroid2 = Picture17.BackColor R4 = centroid2 Mod 256
G4 = (centroid2 \ 256) Mod 256 B4 = (centroid2 \ 256 \ 256) Mod 256 End If
End If Next j Next i
For i = 0 To Picture1.ScaleWidth For j = 0 To Picture1.ScaleHeight c = GetPixel(Picture1.hdc, i, j)
R = c Mod 256
G = (c \ 256) Mod 256 B = (c \ 256 \ 256) Mod 256
R4 = centroid2 Mod 256
G4 = (centroid2 \ 256) Mod 256 B4 = (centroid2 \ 256 \ 256) Mod 256
If Abs(R - R4) < euc And Abs(G - G4) < euc And Abs(B - B4) < euc Then SetPixel Picture33.hdc, i, j, RGB(R, G, B)
(2)
SetPixel Picture33.hdc, i, j, vbBlack
End If Next j Next i End If
ProgressBar1.Value = 100 End Sub
(3)
BAB I
PENDAHULUAN
I.1 Latar Belakang
Pada saat ini kemajuan ilmu komputer sudah sangat pesat, dan sudah banyak perusahaan yang menggunakan komputerisasi dalam berproduksi. Salah satunya adalah perusahaan tekstil atau percetakan yang memerlukan banyak warna dalam produknya. Tugas Akhir ini akan membuat program yang dapat mensegmentasikan atau memisahkan warna pada sebuah citra untuk kemudian dapat ditampilkan satu per satu. Dalam perusahaan tekstil, hal ini berguna agar lebih mudah menghasilkan sebuah gambar atau pola tertentu pada kain. Dan banyak hal lain yang dapat dilakukan dengan pensegmentasian warna ini. Dua buah metoda yang digunakan dalam pensegmentasian warna pada citra ini yaitu menggunakan Algoritma K Nearest Neighbor dan K Means Clustering. Dalam Tugas Akhir ini dilakukan perbandingan hasil pensegmentasian warna secara kualitatif dan kuantitatif. Hasil perbandingan secara kualitatif menunjukkan K Nearest Neighbor lebih unggul namun tidak berbeda jauh dengan K Means Clustering, sedangkan pada hasil perbandingan secara kuantitatif K Means Clustering jauh lebih unggul. Sehingga hasil akhir perbandingan pada Tugas Akhir ini menunjukkan K Means Clustering lebih unggul.
I.2 Identifikasi Masalah
Metoda mana yang lebih baik antara Algoritma K Nearest Neigbor dan K Means Clustering dalam pensegmentasian sebuah citra?
I.3 Tujuan
Merealisasikan perangkat lunak untuk mensegmentasikan warna citra dengan metoda Algoritma K Nearest Neighbor dan K Means Clustering dan membandingkan dua hasil pensegementasian warna tersebut.
(4)
I.4 Pembatasan Masalah
1. Pemrograman menggunakan Visual Basic.
2. Gambar yang disegmentasi berformat RGB 24 bit. 3. Jumlah warna maksimum adalah 16 warna.
I.5 Sistematika Laporan • Bab I Pendahuluan
Membahas latar belakang penulisan, identifikasi masalah dalam penulisan, tujuan penulisan, pembatasan masalah dalam penulisan, dan sistematika penulisan Tugas Akhir ini.
• Bab II Landasan Teori
Membahas teori dasar utama yang digunakan dalam membuat Tugas Akhir ini: Segmentasi (Pengolahan Citra Digital), Algoritma K Nearest Neighbor, Algoritma K Means Clustering dan Visual Basic.
• Bab III Perancangan dan Realisasi
Membahas perancangan dan cara kerja program dalam Tugas Akhir ini: objek dan properti, proses ambil gambar, proses pilih warna otomatis, proses segmentasi, proses K Nearest Neighbor dalam segmentasi warna, proses K Means Clustering dalam segmentasi warna, pembuatan formulir survey, dan proses menghitung persentase error jumlah pixel.
• Bab IV Hasil Akhir
Membahas tentang hasil perancangan dan pembandingan hasil akhir yang telah dilakukan pada lima contoh gambar yang disegmentasi warnanya dalam Tugas Akhir ini.
(5)
BAB V
KESIMPULAN DAN SARAN
V.1 Kesimpulan
Dalam Tugas Akhir ini dapat diambil kesimpulan sebagai berikut:
1. Merealisasikan perangkat lunak untuk mensegmentasikan warna citra dengan metoda Algoritma K Nearest Neighbor dan K Means Clustering telah berhasil dilakukan.
2. Dari hasil penilaian secara kualitatif, K Nearest Neighbor mendapat skor 3,7 (dari skala 5) dan K Means Clustering mendapat skor 3,6 (dari skala 5), hal ini menunjukkan hasil segmentasi warna pada gambar secara penglihatan mata hampir tidak dapat dibedakan, sedangkan secara kuantitatif, K Means Clustering mendapat nilai persentase keberhasilan pengektrasian warna sebesar 100% sama dengan K nearest Neighbor yang juga mendapat nilai persentase keberhasilan pengekstrasian warna sebesar 100%. Jadi, dalam Tugas Akhir ini, Metode K Nearest Neighbor lebih unggul 0,1 point dari metode K Means Clustering, berdasarkan perhitungan secara kualitatif.
V.2 Saran
Untuk menentukan nilai euclidean dihitung secara statistik sehingga tidak diperlukan cara coba-coba.
(6)
DAFTAR PUSTAKA
1. Acharya Tinku, Ray Ajoy K. Image Processing Principles and Application, California : Wiley-Interscience, 2007
2. Basuki Achmad, Palandi Jozua F., Fatchurrochman. Pengolahan Citra Digital menggunakan Visual Basic. Yogyakarta, 2005
3. Daryanto. Belajar Komputer Visual Basic, Bandung :Yrama Widya, 2003 4. Holzner Steven. Visual Basic 6 Black Book. Massachusetts : The Coriolis
Group, 1998
5. Jain Anil K. Fundamental of Digital Image Processing, New Jersey : Prentice Hall International Editions, 1989
6. Pratt William K. Digital Image Processing, California : Wiley-Interscience, 2007
7. Tim Divisi Penelitian dan Pengembangan Madcoms Madiun. Mahir Dalam 7 Hari Pemrograman Visual Basic 6.0. Yogyakarta : Penerbit Andi, 2005 8. http://anthonysteven.wordpress.com/tutorial/algoritma-kmeans
9. http://anthonysteven.wordpress.com/tutorial/algoritma-nearest-neighbor 10.http://en.wikipedia.org/wiki/Euclidean_distance
11.http://en.wikipedia.org/wiki/K-means_algorithm
12.http://en.wikipedia.org/wiki/Segmentation_(image_processing) 13.http://id.wikipedia.org/wiki/KNN
14.http://library.wolfram.com/examples/colorsegmentation/ColorImageSegmenta
tion.htm
15.http://people.revoledu.com/kardi/tutorial/kMean/index.htm 16.http://people.revoledu.com/kardi/tutorial/KNN/index.htm
17.http://www.mathworks.com/products/image/demos/CS.html
18.http://www.mathworks.com/products/image/demos/ipexhistology.html