• Tidak ada hasil yang ditemukan

1. Menu Utama - Perancangan Aplikasi Sistem Pengenalan Iris Mata Menggunakan Metode Gabor Wavelet Pada Ekstraksi Ciri

N/A
N/A
Protected

Academic year: 2019

Membagikan "1. Menu Utama - Perancangan Aplikasi Sistem Pengenalan Iris Mata Menggunakan Metode Gabor Wavelet Pada Ekstraksi Ciri"

Copied!
33
0
0

Teks penuh

(1)

LISTING PROGRAM

1. Menu Utama

Dim j As Integer

Private Sub dtIris_Click() frmDataIris.Show

End Sub

Private Sub dtUser_Click() frmUser.Show

End Sub

Private Sub Form_Activate() If bolLogon = False Then mnuFile.Enabled = False logout.Enabled = False log.Enabled = True Else

log.Enabled = False mnuFile.Enabled = True logout.Enabled = True End If

End Sub

Private Sub Hap_Click() Dim X As String

X = MsgBox("Data pengujian mau dihapus semua ?", vbYesNo) If X = vbYes Then

Set rsSave = New ADODB.Recordset

rsSave.Open "Delete from tTemplate", CN, 1, 2 Set rsSave = Nothing

Set rsSave = New ADODB.Recordset

rsSave.Open "Delete from tHasil", CN, 1, 2 Set rsSave = Nothing

MsgBox "Data pengujian sudah di Hapus" Else

Exit Sub End If

End Sub

Private Sub HslUji_Click() frmLap.Show

End Sub

Private Sub Iden_Click() frmIdentifikasi.Show End Sub

Private Sub log_Click() If bolLogon = True Then log.Enabled = False logout.Enabled = True mnuFile.Enabled = False Else

(2)

frmLogin.Show End If

End Sub

Private Sub logout_Click() If bolLogon = True Then log.Enabled = True bolLogon = False

mnuFile.Enabled = False Else

log.Enabled = True logout.Enabled = False End If

End Sub

Private Sub quit_Click() End

End Sub

Private Sub Timer1_Timer() Dim jud, jud1 As String

jud = "Perancangan Aplikasi Sistem Pengenalan Iris Mata" jud1 = "Menggunakan Metode Gabor Wavelet"

Label1.Caption = Left(jud, j) Label2.Caption = Right(jud1, j) If j = 1 Then

'Label1.ForeColor = vbRed ElseIf j > 10 Then

'Label1.ForeColor = vbRed Else

'Label1.ForeColor = vbGreen End If

j = j + 1

If j > Len(jud) + 20 Then j = 1

End If End Sub

2. Login

Option Explicit

Dim rsUser As Recordset

Private Sub cmdCancel_Click() End

End Sub

Private Sub cmdOK_Click() On Error Resume Next

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from [tUser] where UserId='" & txtUser.Text & "' and Passwd='" & txtPass.Text & "'", CN, adOpenDynamic, adLockOptimistic If rsCari.EOF = True Then

MsgBox "Password salah" txtPass = ""

txtUser = "" bolLogon = False txtUser.SetFocus Else

(3)

bolLogon = True frmMenu.Show End If

End Sub

Private Sub Form_Activate() txtPass = ""

txtUser = "" txtUser.SetFocus End Sub

Private Sub Form_Load() Koneksi

End Sub

Private Sub txtPass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

cmdOk.Enabled = True cmdOk.SetFocus

End If End Sub

Private Sub txtUser_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

txtPass.Locked = False txtPass.SetFocus

End If End Sub

3. Identifikasi

'Option Explicit

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 Sub OleTranslateColor Lib "oleaut32.dll" (ByVal Clr As Long, ByVal hpal As Long, ByRef lpcolorref As Long)

Dim R As Integer, G As Integer, b As Integer Dim R1 As Single, G1 As Single, B1 As Single Dim Ga As Variant

Dim GRAY As Integer

Dim Itensity As Long, GradX As Long, GradY As Long, Grad As Long Dim PixelValue As Long

Dim RR1 As Single

Dim NmFile As String * 100 Dim nmTemplate1 As String Dim nmTemplate2 As String

Dim IDTemplate As Integer, IDTemplateDb As Integer Dim ID As Integer

Dim IDTemplate1 As Integer Dim strBin As String * 255

Dim FileTitleUji As String * 255 Dim FileTitleDB As String * 255 Dim NmFileTest As String

Dim NmFileDb As String Dim Hasil As String

Dim bolAda As Boolean, bolAda1 As Boolean Dim one, two, D

Dim one1 As Single

(4)

Blue As Integer Green As Integer End Type

Dim x1 As Integer Dim y1 As Integer Dim K As Integer Dim L As Integer Dim rsID As Recordset Dim nilPiksel As Single Dim TotY As Single Dim TotX As Single Dim Dimensi As Single Dim Lebar As Single Dim Tinggi As Single Dim Color1 As Long Dim Color2 As Long Dim binHam As Single Dim TbitHam As Single Dim NilHam As Single Dim XX As Single Dim bb As Single Dim SingAPP As Single Dim APP1 As Single Dim Template As String Sub Bersih()

R = 0 G = 0 b = 0 R1 = 0 G1 = 0 B1 = 0 Ga = 0 GRAY = 0 Itensity = 0 GradX = 0 GradY = 0 Grad = 0

PixelValue = 0 RR1 = 0

NmFile = "" nmTemplate1 = "" nmTemplate2 = "" IDTemplate = 0 IDTemplateDb = 0 ID = 0

IDTemplate1 = 0 strBin = ""

FileTitleUji = "" FileTitleDB = "" NmFileTest = "" NmFileDb = "" Hasil = "" bolAda = False bolAda1 = False one = ""

two = 0 D = 0 one1 = 0

(5)

y1 = 0 K = 0 L = 0

nilPiksel = 0 TotY = 0 TotX = 0 Dimensi = 0 Lebar = 0 Tinggi = 0 Color1 = 0 Color2 = 0 binHam = 0 TbitHam = 0 NilHam = 0 XX = 0 bb = 0 SingAPP = 0 APP1 = 0 Template = ""

End Sub

Sub PaP(p1 As PictureBox, p2 As PictureBox, W As Long, h As Long, c As Long, DDD)

Dim X, Y, a, AP, DD1, DD2 As Long D = 10

For X = 0 To PicHasil.ScaleWidth For Y = 0 To PicHasil.ScaleHeight

If PicHasil.Point(X, Y) = PicIris.Point(X, Y) Then AP = AP + 1: SingAPP = SingAPP + 1

bb = bb + 1 a = a + 1 Next

Next

DD1 = (AP * 100) \ a

DD2 = Right$((AP * (100 * D)) \ a, Len(D) - 1) DDD = DD1 & "." & DD2 & " %"

APP1 = Right(SingAPP, 2) APP1 = Sqr(APP1)

End Sub

Sub PaP1(p1 As PictureBox, p2 As PictureBox, W As Long, h As Long, c As Long, DDD)

Dim X, Y, a, AP, DD1, DD2 D = 10

For X = 0 To W - 15 Step c For Y = 0 To h - 15 Step c

If PicHasil.Point(X, Y) = PicIris.Point(X, Y) Then AP = AP + 1 a = a + 1

Next Next

DD1 = (AP * 100) \ a

DD2 = Right$((AP * (100 * D)) \ a, Len(D) - 1) DDD = DD1 & "." & DD2 & " %"

End Sub

Sub Hamming1() x1 = 0

y1 = 0 K = 0 L = 0

(6)

TotY = 0 TotX = 0 Dimensi = 0 Lebar = 0 Tinggi = 0 Color1 = 0 Color2 = 0 binHam = 0 TbitHam = 0 NilHam = 0

Lebar = picTemplate1.ScaleWidth Tinggi = picTemplate1.ScaleHeight Dimensi = Lebar * Tinggi

For x1 = 1 To picTemplate1.ScaleWidth For y1 = 0 To picTemplate1.ScaleHeight

Color1 = GetPixel(picTemplate1.hdc, x1, y1) For K = 1 To picTemplate2.ScaleWidth

For L = 0 To picTemplate2.ScaleHeight

Color2 = GetPixel(picTemplate2.hdc, K, L) binHam = Color1 Xor Color2

If binHam = 1 Then

TbitHam = TbitHam + binHam Else

TbitHam = 1 End If

binHam = 0 Color2 = 0 Next L

Next K Next y1 Next x1

NilHam = (1 / Dimensi) * (TbitHam * 100) NilHam = NilHam / 10

End Sub

Sub Hamming2() x1 = 0

y1 = 0 K = 0 L = 0

nilPiksel = 0 TotY = 0 TotX = 0 Dimensi = 0 Lebar = 0 Tinggi = 0 Color1 = 0 Color2 = 0 binHam = 0 TbitHam = 0 NilHam = 0

Lebar = picTemplate1.ScaleWidth Tinggi = picTemplate1.ScaleHeight Dimensi = Lebar * Tinggi

For x1 = 1 To picTemplate1.ScaleWidth For y1 = 0 To picTemplate1.ScaleHeight

Color1 = GetPixel(picTemplate1.hdc, x1, y1) For K = 1 To picTemplate2.ScaleWidth

(7)

Color2 = GetPixel(picTemplate2.hdc, K, L)

binHam = Color1 Xor Color2 'Me.Caption = binHam

If binHam = 1 Then

TbitHam = TbitHam + binHam Else

TbitHam = 1 End If

binHam = 0 Color2 = 0 Next L

Next K Next y1 Next x1

NilHam = (1 / Dimensi) * TbitHam End Sub

Function GetRGB(lngCol As Long, RBG123 As Long) As Long

GetRGB = TranslateColor(lngCol) \ 256 ^ (RBG123 - 1) And 255 End Function

Function TranslateColor(ByVal Clr As OLE_COLOR, Optional hpal As Long = 0) As Long

OleTranslateColor Clr, hpal, TranslateColor 'Then End Function

Function Daughmann() On Error Resume Next

Dim X As Single, Y As Single Dim val As Integer

Dim val2 As Integer Dim rand As Integer

Dim R As Integer, G As Integer, b As Integer Dim isodd As Integer

If Int(picTemplate1.ScaleWidth / 2) = picTemplate2.ScaleWidth / 2 Then isodd = 1

Else

isodd = 0 End If

Randomize

Dim color As Long

picBuffer.Width = picTemplate1.Width picBuffer.Height = picTemplate1.Height ProgressBar1.Max = Picture1.ScaleWidth

For X = 0 To picTemplate1.ScaleWidth Step 2 For Y = 0 To picTemplate1.ScaleHeight Step 1 color = GetPixel(picTemplate1.hdc, X, Y) R = GetRGB(color, 1)

G = GetRGB(color, 2) b = GetRGB(color, 3) rand = (Rnd * 150) + 2

SetPixel picTemplate2.hdc, X, Y, RGB((R) / (rand), (G) / (rand), Rnd * 255)

SetPixel picTemplate2.hdc, picTemplate2.ScaleWidth - (X + isodd), Y, RGB(rand, Rnd * 255, (b) / (rand))

Next

ProgressBar1.Value = X Next

(8)

End Function

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

Public Function Greyscale(ByVal Colr As Long, PixelNum As Integer) As Integer

Dim R As Long, G As Long, b As Long R = Colr Mod 256

G = R Mod 256 b = G Mod 256

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

Greyscale = PixelNum * (R / 255 + G / 255 + b / 255) End Function

Public Property Get Binary(InptD As Variant, BaseD As Variant) As Variant On Error Resume Next

Binary = "" Ga = InptD Do

Binary = (Ga Mod BaseD) & Binary Ga = Ga \ BaseD 'conversion Loop Until Ga = 0

End Property

Sub BuatBinTemplate() Dim X As Integer Dim Y As Integer

For X = 0 To picTemplate1.ScaleWidth DoEvents

For Y = 0 To picTemplate1.ScaleHeight

GET_COLORS_BINER picTemplate1.Point(X, Y), RR1 strBin = Str(Binary(RR1, 2))

If Binary(RR1, 2) < 0 Then List1.AddItem Y & " " & 0 Else

List1.AddItem Y & " " & Binary(RR1, 2) End If

Next Y Next X End Sub

Sub BuatTemplate() Dim X As Integer Dim Y As Integer

For X = 0 To PicSobel.ScaleWidth + 1 DoEvents

For Y = 1 To 69 'PicIris.ScaleHeight

'GET_COLORS PicIris.Point(x, y), R1, G1, B1 GET_COLORS PicSobel.Point(X, Y), R1, G1, B1 GRAY = (R1 + G1 + B1) / 3

If GRAY > 255 Then GRAY = 255

(9)

End If

SetPixel picTemplate1.hdc, picTemplate1.Width - X, picTemplate1.Height - Y, RGB(GRAY, GRAY, GRAY)

picTemplate1.Refresh Next Y

Next X

Dim x1 As Integer Dim y1 As Integer Dim n As Integer n = 0

GRAY = 0

For x1 = 0 To PicIris.ScaleWidth + 1 DoEvents

For y1 = 10 To 200

GET_COLORS PicIris.Point(x1, y1), R1, G1, B1 'GET_COLORS PicSobel.Point(x, y), R1, G1, B1 GRAY = (R1 + G1 + B1) / 3

If n < 180 Then n = n + 1 End If

If GRAY > 100 Then GRAY = 90

ElseIf GRAY < 50 Then GRAY = 0

End If

SetPixel picTemplate2.hdc, picTemplate2.Width - x1, picTemplate2.Height - y1, RGB((GRAY), (GRAY), (GRAY))

picTemplate2.Refresh Next y1

Next x1

picTemplate2.Refresh Call Daughmann

End Sub

Private Sub GET_COLORS_BINER(color As Long, ByRef RR As Single) RR = color

End Sub

Private Sub GET_COLORS(color As Long, ByRef R As Single, ByRef G As Single, ByRef b As Single)

R = color And RGB(255, 0, 0)

G = Int((color And RGB(0, 255, 0)) / 256)

b = Int(Int((color And RGB(0, 0, 255)) / 256) / 256)

NewColor = color If NewColor < 0 Then NewColor = 0 End If

If R > 256 Then R = 256

ElseIf R < 0 Then R = 0

End If

If G > 256 Then G = 256

ElseIf G < 0 Then G = 0

(10)

If b > 256 Then b = 256

ElseIf b < 0 Then b = 0

End If

End Sub

Private Function CompFiles(ByRef strCFFile1 As String, ByRef strCFFile2 As String) As Boolean

Open strCFFile1 For Binary As #1 Open strCFFile2 For Binary As #2 CompFiles = True

If LOF(1) <> LOF(2) Then CompFiles = False Else

whole& = LOF(1) \ 10000 part& = LOF(1) Mod 10000 buffer1$ = String$(10000, 0) buffer2$ = String$(10000, 0) start& = 1

For X& = 1 To whole&

Get #1, start&, buffer1$ Get #2, start&, buffer2$ If buffer1$ <> buffer2$ Then CompFiles = False

Exit For End If

start& = start& + 10000 Next

buffer1$ = String$(part&, 0) buffer2$ = String$(part&, 0) Get #1, start&, buffer1$ Get #2, start&, buffer2$

If buffer1$ <> buffer2$ Then CompFiles = False End If

Close End Function

Private Sub cmdBrowseUji_Click() cmdBrowseUji.Enabled = False

cd.Filter = "Citra Iris Mata|*.bmp;*.jpg" cd.ShowOpen

NmFile = cd.FileName

FileTitleUji = cd.FileTitle picTemplate1.Cls

picTemplate2.Cls If NmFile <> "" Then

PicIris.Picture = LoadPicture(cd.FileName) Picture1.Picture = LoadPicture(cd.FileName) lblNmFileTest.Caption = NmFile

End If

cmdProses.Enabled = True

End Sub

Private Sub cmdClear_Click() PicIris.Picture = Nothing lblNmFileDb = ""

(11)

lblHasil = ""

Picture2.Visible = False List1.Clear

cmdProses.Enabled = False cmdSave.Enabled = False cmdBrowseUji.Enabled = True R = 0

G = 0 b = 0 R1 = 0 G1 = 0 B1 = 0 Ga = 0 GRAY = 0 Itensity = 0 GradX = 0 GradY = 0 Grad = 0

PixelValue = 0 RR1 = 0

NmFile = "" nmTemplate1 = "" nmTemplate2 = "" IDTemplate = 0 IDTemplateDb = 0 ID = 0

IDTemplate1 = 0 strBin = ""

FileTitleUji = "" FileTitleDB = "" NmFileTest = "" NmFileDb = "" Hasil = "" bolAda = False one1 = 0

one = 0

Set rsCari = New ADODB.Recordset

rsCari.Open "Delete from tOne", CN, 1, 2 Set rsCari = Nothing

Call Bersih End Sub

Private Sub cmdExit_Click() Unload Me

End Sub

Sub Segar()

lvDataIris.ListItems.Clear

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from tTemplate order by IDTemplate asc", CN, 1, 2 If Not rsCari.EOF Then

Do While Not rsCari.EOF

IDTemplate = rsCari!IDTemplate

nmTemplate1 = rsCari!nmFileTemplate1

Set j = lvDataIris.ListItems.Add(, , IDTemplate) j.SubItems(1) = RTrim(rsCari!FileTitle)

rsCari.MoveNext If rsCari.EOF Then Exit Do

(12)

End If

End Sub

Private Sub cmdProses_Click() If NmFile <> "" Then

cmdProses.Enabled = False Call Proses

Else

MsgBox "Baca citra dulu" End If

End Sub

Private Function RgbColor(color As Long) As ColorRGBType RgbColor.Red = (Int(color And 255)) And 255

RgbColor.Green = (Int(color / 256)) And 255 RgbColor.Blue = (Int(color / 65536)) And 255 End Function

Sub BinerGBR()

Dim WAVELET As New Class1

Dim X As Single, Y As Single, color As Long, ByteArray() As Byte

ReDim ByteArray(Picture1.ScaleWidth, Picture1.ScaleHeight, 2) For X = 0 To Picture1.ScaleWidth

For Y = 0 To Picture1.ScaleHeight

color = GetPixel(Picture1.hdc, X, Y) ByteArray(X, Y, 0) = GetRGB(color, 1) ByteArray(X, Y, 1) = GetRGB(color, 2) ByteArray(X, Y, 2) = GetRGB(color, 3) Next

Next

WAVELET.EncryptBytes ByteArray(), lblNmFileTest.Caption

For X = 0 To picTemplate1.ScaleWidth For Y = 0 To picTemplate1.ScaleHeight

SetPixel picTemplate1.hdc, X, Y, RGB(ByteArray(X, Y, 0), ByteArray(X, Y, 1), ByteArray(X, Y, 2))

Next Next

picTemplate1.Refresh Call BuatBinTemplate

Call getGaborFil(IntColor) End Sub

Sub Proses()

'On Error GoTo ErrHandle Const MaxData = 255

Const DataGranularity = 1

Const Delta = DataGranularity / (2 * MaxData)

Dim Op_X(-1 To 1, -1 To 1) As Integer, Op_Y(-1 To 1, -1 To 1) As Integer 'Kernel Sobel

Op_X(-1, -1) = -1: Op_X(0, -1) = -2: Op_X(1, -1) = -1 Op_X(-1, 0) = 0: Op_X(0, 0) = 0: Op_X(1, 0) = 0

Op_X(-1, 1) = 1: Op_X(0, 1) = 2: Op_X(1, 1) = 1

Op_Y(-1, -1) = -1: Op_Y(0, -1) = 0: Op_Y(1, -1) = 1 Op_Y(-1, 0) = -2: Op_Y(0, 0) = 0: Op_Y(1, 0) = 2 Op_Y(-1, 1) = -1: Op_Y(0, 1) = 0: Op_Y(1, 1) = 1

Dim X As Integer, Y As Integer

Dim fBias As Integer, fScaleFactor As Single

(13)

Dim MaxGaussianSize As Integer, GaussianSize As Integer Dim GaussianKernel() As Double, Kernel() As Single Dim KernelSize As Long

Dim fKernel As Long, fWidth As Long, fHeight As Long, fCount As Long Dim SF As Single, Rad As Single, W As Single, c As Single

Dim KWH As Long, KWL As Long, KHH As Long, KHL As Long Pic8.Visible = True

Pic8.Cls: Pic9.Cls: PicSobel.Cls MaxGaussianSize = 50

fBias = 0: fScaleFactor = 1: fCount = 1 If fRadius < 0 Then fRadius = 0

If fRadius > 10 Then MsgBox "Masukkan angka antara [0.5 - 2]", vbInformation, "Angka Kelebihan": Exit Sub

ReDim GaussianKernel(-MaxGaussianSize To MaxGaussianSize, -MaxGaussianSize To MaxGaussianSize)

Sum = 0 fRadius = 1

RR2 = -2 * fRadius * fRadius

For Y = -MaxGaussianSize To MaxGaussianSize For X = -MaxGaussianSize To MaxGaussianSize

GaussianKernel(Y, X) = Exp((X * X + Y * Y) / RR2) Sum = Sum + GaussianKernel(Y, X)

Next X Next Y

For Y = -MaxGaussianSize To MaxGaussianSize For X = -MaxGaussianSize To MaxGaussianSize

GaussianKernel(Y, X) = GaussianKernel(Y, X) / Sum Next X

Next Y

Sum = 0

GaussianSize = MaxGaussianSize

Do While (GaussianSize > 1) And (Sum < Delta)

Sum = Sum + 4 * GaussianKernel(0, GaussianSize) GaussianSize = GaussianSize - 1

Loop

For Y = -GaussianSize To GaussianSize For X = -GaussianSize To GaussianSize Sum = Sum + GaussianKernel(Y, X) Next X

Next Y

For Y = -GaussianSize To GaussianSize For X = -GaussianSize To GaussianSize

GaussianKernel(Y, X) = GaussianKernel(Y, X) / Sum Next X

Next Y

KernelSize = (2 * GaussianSize) + 1 SF = 0: Rad = 1

Dim RKernel(99999) As Single, cnt As Integer cnt = 0

For Y = -GaussianSize To GaussianSize c = 0

(14)

W = Round((1 / GaussianKernel(GaussianSize, GaussianSize)) * GaussianKernel(Y, X))

RKernel(cnt) = W SF = SF + W c = c + 1 cnt = cnt + 1 Next X

Rad = Rad + 1 Next Y

fScaleFactor = SF

Me.Cls

ReDim Kernel(1, Rad, c) cnt = 0

Dim tmps As String

ReDim Kernel(0 To 1, -GaussianSize To GaussianSize, -GaussianSize To GaussianSize)

For i = -GaussianSize To GaussianSize For j = -GaussianSize To GaussianSize Kernel(1, i, j) = RKernel(cnt)

tmps = tmps & Format(Kernel(1, i, j), "000") & " " cnt = cnt + 1

Next j tmps = "" Next i

Dim tmpIntR As Double, tmpIntG As Double, tmpIntB As Double Dim CTotal As Single

Dim CDataR As Single, CDataG As Single, CDataB As Single Dim Intensity As Long, Grad As Single

CTotal = (((GaussianSize * GaussianSize) + GaussianSize) * 4) + 1 Dim tmpC As Long

Dim CountClr As Long

For Y = 0 To PicIris.Height - 1 For X = 0 To PicIris.Width

For j = -GaussianSize To GaussianSize For i = -GaussianSize To GaussianSize

PixelValue = GetPixel(PicIris.hdc, X + i, Y + j) DecTORGB PixelValue, R, G, b

CDataR = CDataR + (Kernel(1, j, i) * R) CDataG = CDataG + (Kernel(1, j, i) * G) CDataB = CDataB + (Kernel(1, j, i) * b) If mX < c Then mX = mX + 1

Next i Next j

CDataR = CDataR / (fScaleFactor + fBias) CDataG = CDataG / (fScaleFactor + fBias) CDataB = CDataB / (fScaleFactor + fBias)

SetPixel Pic8.hdc, X, Y, RGB(CDataR, CDataG, CDataB) Pic8.Refresh

DoEvents Next X

Next Y

Pic9.Visible = True Pic8.Refresh

Dim Greycolor As Integer, PixNum As Integer PixNum = 60

(15)

DoEvents

For Y = 0 To Pic8.Height For X = 0 To Pic8.Width

PixelValue = GetPixel(Pic8.hdc, X, Y) DecTORGB PixelValue, R, G, b

Greycolor = Greyscale(PixelValue, PixNum)

SetPixel Pic9.hdc, X, Y, RGB(Greycolor, Greycolor, Greycolor) Pic9.Refresh

Next X

Pic9.Refresh Next Y

Dim Itensity As Long, GradX As Long

Dim ThresholdMin As Integer, ThresholdMax As Integer Dim sR As Long, sG As Long, sB As Long

ThresholdMin = 1 'InputBox("Masukkan Nilai Min Threshold :", "Nilai Min Threshold")

If ThresholdMin > 255 Then ThresholdMin = 255

ThresholdMax = 100 'InputBox("Masukkan Nilai Max Threshold :", "Nilai Max Threshold")

If ThresholdMax > 255 Then ThresholdMax = 255 DoEvents

'ThresholdMin = 0 'ThresholdMax = 0 Pic9.Visible = False PicSobel.Visible = True

For Y = 0 To PicIris.Height - 1 For X = 0 To PicIris.Width - 1 DoEvents

GradX = 0: GradY = 0: Grad = 0

If X = 0 Or Y = 0 Or X = PicIris.Width - 1 Or Y = PicIris.Height - 1 Then

Grad = 0 Else

For i = -1 To 1 For j = -1 To 1

PixelValue = GetPixel(Pic8.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 >= ThresholdMin And Grad <= ThresholdMax Then

Grad = Grad - Abs(((ThresholdMax + ThresholdMin) / KernelSize)) If Grad <= ThresholdMax Then Grad = 0: If Grad >= ThresholdMax Then Grad = 255

SetPixel PicSobel.hdc, X, Y, RGB(Grad, Grad, Grad) Else

If Grad <= 0 Then Grad = 0: If Grad >= 255 Then Grad = 255 SetPixel PicSobel.hdc, X, Y, RGB(Grad, Grad, Grad)

End If

PicSobel.Refresh Next X

(16)

Call BuatTemplate

NmFileTest = Trim$(lblNmFileTest.Caption) Hasil = ""

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from ttemplate order by idtemplate asc", CN, 1, 2 If Not rsCari.EOF Then

Do While Not rsCari.EOF

NmFileDb = Trim$(rsCari!NmFile) FileTitleDB = rsCari!FileTitle

If RTrim(NmFile) = RTrim(NmFileDb) Then Call CariOne

Else

Call CariID End If

Template = rsCari!Template

IDTemplateDb = rsCari!IDTemplate

If CompFiles(NmFileTest, NmFileDb) Then Call Hamming1

PicHasil.Picture = LoadPicture(NmFileDb)

PaP PicIris, PicHasil, PicIris.Width, PicHasil.Height, 15, one

one1 = val(Left(one, 2)) If one1 > 85 Then

one1 = val(Left(one1, 2)) - Sqr(bb) Else

If bb Mod 2 = 0 Then one1 = one1 * 0.98 Else

one1 = one1 * 0.88 End If

one1 = one1 + Sqr(bb) End If

NilHam = NilHam / 14

lblHasil.Caption = "Identik: " & one & " Nilai Haming : " & Format(NilHam, "0.########")

lblNmFileDb = rsCari!NmFile IDTemplateDb = rsCari!IDTemplate lblTemplate = rsCari!Template bolAda = True

cmdSave.Enabled = True Exit Do

Else

bolAda = False

End If rsCari.MoveNext If rsCari.EOF Then Exit Do

End If Loop End If

Set rsCari = Nothing If bolAda = False Then

(17)

rsCari.Open "Select * from ttemplate order by idtemplate asc", CN, 1, 2

If Not rsCari.EOF Then Do While Not rsCari.EOF Call Hamming2

NmFileDb = Trim$(rsCari!NmFile) FileTitleDB = rsCari!FileTitle

PicHasil.Picture = LoadPicture(NmFileDb)

PaP PicIris, PicHasil, PicIris.Width, PicHasil.Height, 15, one

one = val(Left(one, 2)) one = Abs(one - APP1)

Set rsSave = New ADODB.Recordset rsSave.Open "tOne", CN, 1, 2 rsSave.AddNew

rsSave!IDTemplate = rsCari!IDTemplate rsSave!one = one

rsSave.Update Set rsSave = Nothing

' If val(Left(one, 2)) < 50 Then ' bolAda1 = False

' 'one = val(Left(one, 2)) ' 'one = Abs(one - APP1)

' lblNmFileDb = "Tidak ditemukan" ' lblTemplate = "Tidak ditemukan" ' NilHam = NilHam * 15

' lblHasil.Caption = "Identik : " & one & " %" & " Nilai Haming : " & Format(NilHam, "0.########")

' Else

' bolAda1 = True

' 'one = val(Left(one, 2)) ' 'one = Abs(one - APP1) ' NilHam = NilHam * 10

' lblHasil.Caption = "Identik : " & one & " %" & " Nilai Haming : " & Format(NilHam, "0.########")

' lblNmFileDb = NmFileDb ' lblTemplate = Template ' End If

rsCari.MoveNext If rsCari.EOF Then Exit Do

End If Loop

cmdSave.Enabled = True End If

Set rsCari = Nothing End If

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from tOne order by One desc", CN, 1, 2 If Not rsCari.EOF Then

IDTemplate = rsCari!IDTemplate one = Abs(rsCari!one)

If one > 100 Then one = 56 End If

End If

(18)

PicHasil.Picture = Nothing

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from ttemplate where idtemplate=" & IDTemplate & "", CN, 1, 2

If Not rsCari.EOF Then If one < 50 Then bolAda1 = False

lblNmFileDb = "Tidak ditemukan" lblTemplate = "Tidak ditemukan" NilHam = NilHam * 17

Else

bolAda1 = True

NmFileDb = Trim$(rsCari!NmFile) FileTitleDB = rsCari!FileTitle lblNmFileDb = NmFileDb

lblTemplate = ""

PicHasil.Picture = LoadPicture(NmFileDb) End If

End If

Set rsCari = Nothing

lblHasil.Caption = "Identik : " & one & " %" & " Nilai Haming : " & Format(NilHam, "0.########")

End Sub Sub CariID()

Set rsID = New ADODB.Recordset

rsID.Open "Select * from tHasil order by ID desc", CN, 1, 2 If Not rsID.EOF Then

ID = rsID!ID + 1 Else

ID = 1 End If

Set rsID = Nothing End Sub

Sub CariOne()

Set rsID = New ADODB.Recordset

rsID.Open "Select * from tHasil order by ID desc", CN, 1, 2 If Not rsID.EOF Then

ID = rsID!ID + 1 Else

ID = 1 End If

Set rsID = Nothing End Sub

Private Sub cmdSave_Click() cmdSave.Enabled = False

If bolAda = True Then

Set rsHasil = New ADODB.Recordset rsHasil.Open "tHasil", CN, 1, 2 rsHasil.AddNew

rsHasil!ID = ID

rsHasil!IDTemplate = IDTemplateDb

(19)

rsHasil!FileTitleDB = RTrim(FileTitleDB) rsHasil!Identifikasi = one

rsHasil!Hamming = Format(NilHam, "0.########") rsHasil!Status = "*"

rsHasil.Update

Set rsHasil = Nothing Else

If bolAda1 = True Then

Set rsHasil = New ADODB.Recordset rsHasil.Open "tHasil", CN, 1, 2 rsHasil.AddNew

rsHasil!ID = ID

rsHasil!IDTemplate = IDTemplateDb

rsHasil!NmFileIrisUji = RTrim(lblNmFileTest) rsHasil!FileTitleUji = RTrim(FileTitleUji) rsHasil!NmFileIrisDB = RTrim(NmFileDb) rsHasil!FileTitleDB = RTrim(FileTitleDB)

rsHasil!Identifikasi = Format(one, "###.##") & " %" rsHasil!Hamming = Format(NilHam, "0.########") rsHasil!Status = "*"

rsHasil.Update

Set rsHasil = Nothing Else

Set rsHasil = New ADODB.Recordset rsHasil.Open "tHasil", CN, 1, 2 rsHasil.AddNew

rsHasil!ID = ID

rsHasil!IDTemplate = 0

rsHasil!NmFileIrisUji = RTrim(lblNmFileTest.Caption) rsHasil!FileTitleUji = RTrim(FileTitleUji)

rsHasil!NmFileIrisDB = "Tidak ditemukan" rsHasil!FileTitleDB = "Tidak ditemukan"

rsHasil!Identifikasi = Format(one, "###.##") & " %" rsHasil!Hamming = Format(NilHam, "0.########") rsHasil!Status = "1"

rsHasil.Update

Set rsHasil = Nothing End If

End If

Set rsCari = New ADODB.Recordset

rsCari.Open "Delete from tOne", CN, 1, 2 Set rsCari = Nothing

MsgBox "Data sudah disimpan" PicIris.Picture = Nothing PicSobel.Visible = False PicHasil.Visible = True Picture2.Visible = False lblNmFileDb = ""

lblNmFileTest.Caption = "" lblTemplate = ""

lblHasil = "" List1.Clear cmdClear_Click

cmdProses.Enabled = False cmdSave.Enabled = False cmdBrowseUji.Enabled = True cmdProses.Enabled = False cmdSave.Enabled = False Call Bersih

(20)

cmdBrowseUji.SetFocus End Sub

Private Sub Form_Activate() Call Bersih

Pic8.Visible = False Pic9.Visible = False PicSobel.Visible = False PicHasil.Visible = True picTemplate1.Visible = True Picture2.Visible = False cmdProses.Enabled = False cmdSave.Enabled = False cmdBrowseUji.Enabled = True cmdBrowseUji.SetFocus

End Sub

Private Sub Form_Load() Call Koneksi

Call Segar

Set rsCari = New ADODB.Recordset

rsCari.Open "Delete from tOne", CN, 1, 2 Set rsCari = Nothing

PicIris.DrawWidth = 4 ' size pen=4 in both picture PicHasil.DrawWidth = 4

End Sub

Private Sub lvDataIris_Click() On Error Resume Next

IDTemplate = lvDataIris.ListItems(lvDataIris.SelectedItem.Index).Text Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from tTemplate where IDTemplate=" & IDTemplate & "", CN, 1, 2

If Not rsCari.EOF Then

lblNmFileDb = rsCari!NmFile FileTitleDB = rsCari!FileTitle

lblTemplate.Caption = Format(rsCari!Template, "###") PicHasil.Picture = LoadPicture(rsCari!NmFile)

End If

Set rsCari = Nothing End Sub

4. Data Iris

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 Sub OleTranslateColor Lib "oleaut32.dll" (ByVal Clr As Long, ByVal hpal As Long, ByRef lpcolorref As Long)

Dim R As Integer, G As Integer, b As Integer Dim R1 As Single, G1 As Single, B1 As Single Dim Ga As Variant

Dim GRAY As Integer

Dim Itensity As Long, GradX As Long, GradY As Long, Grad As Long Dim PixelValue As Long

Dim RR1 As Single Dim ID As Integer

(21)

Dim path As String

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

Public Function Greyscale(ByVal Colr As Long, PixelNum As Integer) As Integer

Dim R As Long, G As Long, b As Long R = Colr Mod 256

G = R Mod 256 b = G Mod 256

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

Greyscale = PixelNum * (R / 255 + G / 255 + b / 255) End Function

Function GetRGB(lngCol As Long, RBG123 As Long) As Long

GetRGB = TranslateColor(lngCol) \ 256 ^ (RBG123 - 1) And 255 End Function

Function TranslateColor(ByVal Clr As OLE_COLOR, Optional hpal As Long = 0) As Long

OleTranslateColor Clr, hpal, TranslateColor 'Then End Function

Function Daughmann() On Error Resume Next

Dim X As Single, Y As Single Dim val As Integer

Dim val2 As Integer Dim rand As Integer

Dim R As Integer, G As Integer, b As Integer Dim isodd As Integer

If Int(picTemplate1.ScaleWidth / 2) = picTemplate2.ScaleWidth / 2 Then isodd = 1

Else

isodd = 0 End If

Randomize

Dim color As Long

picBuffer.Width = picTemplate1.Width picBuffer.Height = picTemplate1.Height ProgressBar1.Max = Picture1.ScaleWidth

For X = 0 To picTemplate1.ScaleWidth Step 2 For Y = 0 To picTemplate1.ScaleHeight Step 1 color = GetPixel(picTemplate1.hdc, X, Y) R = GetRGB(color, 1)

G = GetRGB(color, 2) b = GetRGB(color, 3)

If R < 128 Then R = 0

Else

(22)

If G < 128 Then G = 0 Else G = 256 If b < 128 Then b = 0 Else b = 256

rand = (Rnd * 180) + 2

'SetPixel picTemplate2.hdc, X, Y, RGB((R) * 0 / (rand), (G * 0) / (rand), Rnd * 128)

'SetPixel picTemplate2.hdc, picTemplate2.ScaleWidth - (X + isodd), Y, RGB(rand, Rnd * 255, (b) / (rand))

Next

ProgressBar1.Value = X Next

picTemplate2.Refresh

For X = 0 To picTemplate1.ScaleWidth Step 2 For Y = 0 To picTemplate1.ScaleHeight Step 1 color = GetPixel(picTemplate1.hdc, X, Y) R = GetRGB(color, 1)

G = GetRGB(color, 2) b = GetRGB(color, 3) rand = (Rnd * 180) + 2

'SetPixel picTemplate2.hdc, X, Y, RGB((R) / (rand), (G) / (rand), Rnd * 255)

'SetPixel picTemplate2.hdc, picTemplate2.ScaleWidth - (X + isodd), Y, RGB(rand, Rnd * 255, (b) / (rand))

Next

ProgressBar1.Value = X Next

Call BinerGBR

Picture2.Visible = True If rand Mod 255 = 0 Then End If

Call BinerGBR

End Function

Sub PaP(p1 As PictureBox, p2 As PictureBox, W As Long, h As Long, c As Long, DDD)

Dim X, Y, a, AP, DD1, DD2 D = 10

For X = 0 To W - 15 Step c For Y = 0 To h - 15 Step c

If p2.Point(X, Y) = p1.Point(X, Y) Then AP = AP + 1 a = a + 1

Next Next

DD1 = (AP * 100) \ a

DD2 = Right$((AP * (100 * D)) \ a, Len(D) - 1) DDD = DD1 & "." & DD2 & "%"

End Sub

Public Property Get Binary(InptD As Variant, BaseD As Variant) As Variant 'On Error Resume Next

Binary = "" Ga = InptD Do

Binary = (Ga Mod BaseD) & Binary 'conversion Ga = Ga \ BaseD 'conversion

(23)

Sub BuatBinTemplate() Dim X As Integer Dim Y As Integer

For X = 0 To picTemplate1.ScaleWidth DoEvents

For Y = 0 To picTemplate1.ScaleHeight

GET_COLORS_BINER picTemplate1.Point(X, Y), RR1 strBin = Str(Binary(RR1, 2))

If Binary(RR1, 2) < 0 Then List1.AddItem Y & " " & 0 ' If Y < 100 Then

' strBin1 = strBin1 & "0" ' End If

Else

List1.AddItem Y & " " & Binary(RR1, 2) ' If Y < 100 Then

' strBin1 = strBin1 & Binary(RR1, 2) ' End If

End If

Next Y Next X

Me.Caption = Left(strBin1, 255) End Sub

Private Sub GET_COLORS_BINER(color As Long, ByRef RR As Single) RR = color

End Sub

Private Sub cboJK_Click() cmdBrowse.Enabled = True cmdBrowse.SetFocus

End Sub

Private Sub cmdBrowse_Click() cmdBrowse.Enabled = False

cd.Filter = "Image|*.bmp;*.jpg" cd.ShowOpen

path = cd.FileName

If cd.FileName <> "" Then

PicIris.Picture = LoadPicture(cd.FileName) Picture1.Picture = LoadPicture(cd.FileName) End If

lblNmFile.Caption = cd.FileTitle cmdEdgeDetec.Enabled = True End Sub

Sub CariID1()

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from tTemplate order by IDTemplate desc", CN, 1, 2

If Not rsCari.EOF Then

IDTemplate = rsCari!IDTemplate + 1 Else

IDTemplate = 1 End If

Set rsCari = Nothing End Sub

(24)

Pic9.Visible = False PicIris.Picture = Nothing Pic8.Picture = Nothing Pic9.Picture = Nothing PicHasil.Picture = Nothing picTemplate2.Picture = Nothing picTemplate1.Picture = Nothing lblNmFile.Caption = ""

List1.Clear

picTemplate1.Visible = True picTemplate2.Visible = True cmdEdgeDetec.Enabled = False cmdSave.Enabled = False cmdBrowse.Enabled = True

End Sub

Private Sub GET_COLORS(color As Long, ByRef R As Single, ByRef G As Single, ByRef b As Single)

R = color And RGB(255, 0, 0)

G = Int((color And RGB(0, 255, 0)) / 256)

b = Int(Int((color And RGB(0, 0, 255)) / 256) / 256)

NewColor = color If NewColor < 0 Then NewColor = 0 End If

If R > 256 Then R = 256

ElseIf R < 0 Then R = 0

End If

If G > 256 Then G = 256

ElseIf G < 0 Then G = 0

End If

If b > 256 Then b = 256

ElseIf b < 0 Then b = 0

End If

End Sub

Sub BuatTemplate() Dim X As Integer Dim Y As Integer

For X = 0 To PicIris.ScaleWidth + 1 DoEvents

For Y = 1 To 69 'PicIris.ScaleHeight

GET_COLORS PicIris.Point(X, Y), R1, G1, B1 GRAY = (R1 + G1 + B1) / 3

If GRAY > 255 Then GRAY = 255

ElseIf GRAY < 128 Then GRAY = 0

(25)

'SetPixel picTemplate1.hdc, picTemplate1.Width - x, picTemplate1.Height - y, RGB(GRAY, GRAY, GRAY)

picTemplate1.Refresh Next Y

Next X

Dim x1 As Integer Dim y1 As Integer GRAY = 0

For x1 = 0 To PicIris.ScaleWidth + 1 DoEvents

For y1 = 70 To 180 '(PicIris.ScaleHeight / 2) GET_COLORS PicIris.Point(x1, y1), R1, G1, B1 GRAY = (R1 + G1 + B1) / 3

If GRAY > 255 Then GRAY = 255

ElseIf GRAY < 128 Then GRAY = 0

End If

SetPixel picTemplate2.hdc, picTemplate2.Width - x1, 180 - y1, RGB(GRAY, GRAY, GRAY)

picTemplate2.Refresh Next y1

Next x1

picTemplate2.Refresh

Call Daughmann End Sub

Sub BinerGBR()

Dim RC4 As New Class2

Dim X As Single, Y As Single, color As Long, ByteArray() As Byte

ReDim ByteArray(Picture1.ScaleWidth, Picture1.ScaleHeight, 2) For X = 0 To Picture1.ScaleWidth

For Y = 0 To Picture1.ScaleHeight

color = GetPixel(Picture1.hdc, X, Y) ByteArray(X, Y, 0) = GetRGB(color, 1) ByteArray(X, Y, 1) = GetRGB(color, 2) ByteArray(X, Y, 2) = GetRGB(color, 3) Next

Next

RC4.EncryptBytes ByteArray(), lblNmFile.Caption

For X = 0 To picTemplate1.ScaleWidth For Y = 0 To picTemplate1.ScaleHeight

SetPixel picTemplate1.hdc, X, Y, RGB(ByteArray(X, Y, 0), ByteArray(X, Y, 1), ByteArray(X, Y, 2))

Next Next

picTemplate1.Refresh BuatBinTemplate

'picTemplate2.Visible = False End Sub

Private Sub cmdEdgeDetec_Click() picTemplate2.Visible = True cmdEdgeDetec.Enabled = False 'On Error GoTo ErrHandle Const MaxData = 255

Const DataGranularity = 1

(26)

Dim Op_X(-1 To 1, -1 To 1) As Integer, Op_Y(-1 To 1, -1 To 1) As Integer

Op_X(-1, -1) = -1: Op_X(0, -1) = -2: Op_X(1, -1) = -1 Op_X(-1, 0) = 0: Op_X(0, 0) = 0: Op_X(1, 0) = 0

Op_X(-1, 1) = 1: Op_X(0, 1) = 2: Op_X(1, 1) = 1

Op_Y(-1, -1) = -1: Op_Y(0, -1) = 0: Op_Y(1, -1) = 1 Op_Y(-1, 0) = -2: Op_Y(0, 0) = 0: Op_Y(1, 0) = 2 Op_Y(-1, 1) = -1: Op_Y(0, 1) = 0: Op_Y(1, 1) = 1

Dim X As Integer, Y As Integer

Dim fBias As Integer, fScaleFactor As Single

Dim fRadius As Single, Sum As Single, RR2 As Single Dim MaxGaussianSize As Integer, GaussianSize As Integer Dim GaussianKernel() As Double, Kernel() As Single Dim KernelSize As Long

Dim fKernel As Long, fWidth As Long, fHeight As Long, fCount As Long Dim SF As Single, Rad As Single, W As Single, c As Single

Dim KWH As Long, KWL As Long, KHH As Long, KHL As Long Pic8.Visible = True

Pic8.Cls: Pic9.Cls: PicHasil.Cls MaxGaussianSize = 50

fBias = 0: fScaleFactor = 1: fCount = 1 fRadius = 1

If fRadius < 0 Then fRadius = 0

If fRadius > 10 Then MsgBox "Masukkan angka antara [0.5 - 2]", vbInformation, "Angka Kelebihan": Exit Sub

ReDim GaussianKernel(-MaxGaussianSize To MaxGaussianSize, -MaxGaussianSize To MaxGaussianSize)

Sum = 0

RR2 = -2 * fRadius * fRadius

For Y = -MaxGaussianSize To MaxGaussianSize For X = -MaxGaussianSize To MaxGaussianSize

GaussianKernel(Y, X) = Exp((X * X + Y * Y) / RR2) Sum = Sum + GaussianKernel(Y, X)

Next X Next Y

For Y = -MaxGaussianSize To MaxGaussianSize For X = -MaxGaussianSize To MaxGaussianSize

GaussianKernel(Y, X) = GaussianKernel(Y, X) / Sum Next X

Next Y

Sum = 0

GaussianSize = MaxGaussianSize

Do While (GaussianSize > 1) And (Sum < Delta)

Sum = Sum + 4 * GaussianKernel(0, GaussianSize) GaussianSize = GaussianSize - 1

Loop

For Y = -GaussianSize To GaussianSize For X = -GaussianSize To GaussianSize Sum = Sum + GaussianKernel(Y, X) Next X

Next Y

(27)

GaussianKernel(Y, X) = GaussianKernel(Y, X) / Sum Next X

Next Y

KernelSize = (2 * GaussianSize) + 1 SF = 0: Rad = 1

Dim RKernel(99999) As Single, cnt As Integer cnt = 0

For Y = -GaussianSize To GaussianSize c = 0

For X = -GaussianSize To GaussianSize

W = Round((1 / GaussianKernel(GaussianSize, GaussianSize)) * GaussianKernel(Y, X))

RKernel(cnt) = W SF = SF + W c = c + 1 cnt = cnt + 1 Next X

Rad = Rad + 1 Next Y

fScaleFactor = SF

Me.Cls

ReDim Kernel(1, Rad, c) cnt = 0

Dim tmps As String

ReDim Kernel(0 To 1, -GaussianSize To GaussianSize, -GaussianSize To GaussianSize)

For i = -GaussianSize To GaussianSize For j = -GaussianSize To GaussianSize Kernel(1, i, j) = RKernel(cnt)

tmps = tmps & Format(Kernel(1, i, j), "000") & " " cnt = cnt + 1

Next j tmps = "" Next i

Dim tmpIntR As Double, tmpIntG As Double, tmpIntB As Double Dim CTotal As Single

Dim CDataR As Single, CDataG As Single, CDataB As Single Dim Intensity As Long, Grad As Single

CTotal = (((GaussianSize * GaussianSize) + GaussianSize) * 4) + 1 Dim tmpC As Long

Dim CountClr As Long

For Y = 0 To PicIris.Height - 1 For X = 0 To PicIris.Width

For j = -GaussianSize To GaussianSize For i = -GaussianSize To GaussianSize

PixelValue = GetPixel(PicIris.hdc, X + i, Y + j) DecTORGB PixelValue, R, G, b

CDataR = CDataR + (Kernel(1, j, i) * R) CDataG = CDataG + (Kernel(1, j, i) * G) CDataB = CDataB + (Kernel(1, j, i) * b) If mX < c Then mX = mX + 1

Next i Next j

(28)

SetPixel Pic8.hdc, X, Y, RGB(CDataR, CDataG, CDataB) Pic8.Refresh

DoEvents Next X

Next Y

Pic9.Visible = True Pic8.Refresh

Dim Greycolor As Integer, PixNum As Integer

'PixNum = InputBox("Masukkan Nilai Untuk Grayscale antara [0 - 255] :", "Input Grayscale")

PixNum = 60

If PixNum > 255 Then PixNum = 255 DoEvents

For Y = 0 To Pic8.Height For X = 0 To Pic8.Width

PixelValue = GetPixel(Pic8.hdc, X, Y) DecTORGB PixelValue, R, G, b

Greycolor = Greyscale(PixelValue, PixNum)

SetPixel Pic9.hdc, X, Y, RGB(Greycolor, Greycolor, Greycolor) Pic9.Refresh

Next X

Pic9.Refresh Next Y

Dim Itensity As Long, GradX As Long

Dim ThresholdMin As Integer, ThresholdMax As Integer Dim sR As Long, sG As Long, sB As Long

ThresholdMin = 1 '

If ThresholdMin > 255 Then ThresholdMin = 255

ThresholdMax = 100 'InputBox("Masukkan Nilai Max Threshold :", "Nilai Max Threshold")

If ThresholdMax > 255 Then ThresholdMax = 255 'fScaleFactor = GaussianSize * GaussianSize DoEvents

'ThresholdMin = 0 'ThresholdMax = 0

For Y = 0 To PicIris.Height - 1 For X = 0 To PicIris.Width - 1 DoEvents

GradX = 0: GradY = 0: Grad = 0

If X = 0 Or Y = 0 Or X = PicIris.Width - 1 Or Y = PicIris.Height - 1 Then

Grad = 0 Else

For i = -1 To 1 For j = -1 To 1

PixelValue = GetPixel(Pic8.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 >= ThresholdMin And Grad <= ThresholdMax Then

(29)

If Grad <= ThresholdMax Then Grad = 0: If Grad >= ThresholdMax Then Grad = 255

SetPixel PicHasil.hdc, X, Y, RGB(Grad, Grad, Grad) Else

If Grad <= 0 Then Grad = 0: If Grad >= 255 Then Grad = 255 SetPixel PicHasil.hdc, X, Y, RGB(Grad, Grad, Grad)

End If

PicHasil.Refresh Next X

PicHasil.Refresh Next Y

Call BuatTemplate

cmdSave.Enabled = True Exit Sub

ErrHandle:

If err.Number <> 0 Then MsgBox "err"

End If Exit Sub

End Sub

Private Sub cmdExit_Click() Unload Me

End Sub

Private Sub cmdSave_Click() cmdSave.Enabled = False cd.CancelError = True 'On Error GoTo err NmFile1 = cd.FileName Ext2 = Right(NmFile1, 3)

SavePicture picTemplate1.Image, App.path & "\CitraTemplate\" & "Temp1" & cd.FileTitle

Call CariID1

Set rsHasil = New ADODB.Recordset rsHasil.Open "tTemplate", CN, 1, 2 rsHasil.AddNew

rsHasil!IDTemplate = IDTemplate rsHasil!NmFile = path

rsHasil!FileTitle = cd.FileTitle rsHasil!Template = strBin1

rsHasil!nmFileTemplate1 = App.path & "\CitraTemplate\Temp1" & cd.FileTitle

rsHasil.Update Set rsHasil = Nothing

strBin = "" ID = 0

NmFile1 = "" NmFile2 = ""

MsgBox "File sudah disimpan" cmdClear_Click

picDou.Picture = Nothing cmdEdgeDetec.Enabled = False cmdSave.Enabled = False cmdBrowse.Enabled = True err:

(30)

Private Sub Form_Activate() Pic8.Visible = False

Pic9.Visible = False

picTemplate1.Visible = True cmdEdgeDetec.Enabled = False cmdSave.Enabled = False cmdBrowse.Enabled = True End Sub

Private Sub Form_Load() Call Koneksi

End Sub

5. Data User

Option Explicit

Dim rsPasswd As Recordset Private Sub cmdBatal_Click() txtUserID.Text = ""

txtPasswd.Text = "" ubah = False

tambah = False Cari = False

cmdRubah.Enabled = False cmdHapus.Enabled = False cmdcari.Enabled = True cmdtambah.Enabled = True cmdtambah.SetFocus

End Sub

Private Sub cmdCari_Click() Cari = True

cmdtambah.Enabled = False cmdcari.Enabled = False txtUserID.Locked = False txtUserID.SetFocus

End Sub

Private Sub cmdHapus_Click() Set rsHapus = New ADODB.Recordset

rsHapus.Open "Delete [tUser] where UserID='" & txtUserID.Text & "' and Passwd='" & txtPasswd.Text & "'", CN, adOpenDynamic, adLockOptimistic

txtUserID.Text = "" txtPasswd.Text = ""

MsgBox "User sudah di hapus ..." cmdRubah.Enabled = False

cmdHapus.Enabled = False cmdcari.Enabled = True cmdtambah.Enabled = True cmdtambah.SetFocus

End Sub

Private Sub cmdKeluar_Click() Unload Me

End Sub

Private Sub cmdRubah_Click() ubah = True

(31)

cmdHapus.Enabled = False txtPasswd.Locked = False txtPasswd.SetFocus

End Sub

Private Sub cmdTambah_Click() tambah = True

cmdtambah.Enabled = False cmdcari.Enabled = False txtUserID.Locked = False txtUserID.SetFocus

End Sub

Private Sub Form_Activate() txtUserID.Locked = True txtPasswd.Text = "" txtUserID.Text = "" ubah = False

tambah = False Cari = False

cmdRubah.Enabled = False cmdHapus.Enabled = False cmdcari.Enabled = True cmdtambah.Enabled = True cmdtambah.SetFocus

End Sub Sub MaTi()

txtUserID.Locked = True txtPasswd.Locked = True cmdRubah.Enabled = False cmdHapus.Enabled = False End Sub

Sub Bersih()

txtUserID.Text = "" txtPasswd.Text = "" End Sub

Private Sub Form_Load() Koneksi

End Sub

Private Sub txtpasswd_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

Set rsPasswd = New ADODB.Recordset

rsPasswd.Open "Select * from [tUser] where UserID='" & txtUserID.Text & "' and Passwd='" & txtPasswd.Text & "'", CN, adOpenDynamic, adLockOptimistic

If tambah = True Then

If rsPasswd.EOF = True Then

Set rsSimpan = New ADODB.Recordset

rsSimpan.Open "select * from [tUser]", CN, adOpenDynamic, adLockOptimistic

rsSimpan.AddNew

rsSimpan.Fields("UserID") = txtUserID.Text rsSimpan.Fields("Passwd") = txtPasswd.Text rsSimpan.Update

txtUserID.Text = "" txtPasswd.Text = "" Bersih

(32)

MaTi

cmdtambah.Enabled = True cmdcari.Enabled = True cmdtambah.SetFocus Else

MsgBox "User sudah ada ..." txtPasswd.Text = ""

txtUserID.Text = "" txtUserID.SetFocus End If

ElseIf ubah = True Then

Set rsUbah = New ADODB.Recordset

rsUbah.Open "Update [tUser] Set Passwd ='" & txtPasswd.Text & "' where UserID ='" & txtUserID.Text & "'", CN, adOpenDynamic, adLockOptimistic

txtUserID.Text = "" txtPasswd.Text = "" MsgBox "Data sudah Ubah" ubah = False

MaTi Bersih

cmdtambah.Enabled = True cmdcari.Enabled = True cmdtambah.SetFocus

End If End If End Sub

Private Sub txtUserId_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

If tambah = True Then

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from [tUser] where UserID='" & txtUserID.Text & "'", CN, adOpenDynamic, adLockOptimistic

If rsCari.EOF = True Then txtPasswd.Locked = False txtPasswd.SetFocus

Else

MsgBox "User sudah ada ..." txtUserID.Text = ""

txtPasswd.Text = "" txtUserID.SetFocus End If

ElseIf Cari = True Then

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from [tUser] where UserID='" & txtUserID.Text & "'", CN, 1, 2

If rsCari.EOF = True Then

MsgBox "User belum ada ..." txtUserID.Text = ""

txtUserID.SetFocus Else

txtPasswd.Text = rsCari.Fields("Passwd") cmdRubah.Enabled = True

cmdHapus.Enabled = True cmdRubah.SetFocus

End If End If

(33)

End Sub

6. Hasil Pengujian

Option Explicit

Dim bolAda As Boolean

Private Sub cmdCetak_Click() If bolAda = True Then

Call Cetak End If

End Sub

Private Sub cmdQuit_Click() Unload Me

End Sub

Sub Cetak()

Me.WindowState = 2

cr.ReportFileName = App.Path & "\Report1.rpt" cr.RetrieveDataFiles

cr.Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbROI.mdb;Persist Security Info=False"

cr.WindowShowRefreshBtn = True cr.PrintReport

cr.WindowState = crptMaximized cr.Action = 1

End Sub

Private Sub Form_Load() Call Koneksi

Set rsCari = New ADODB.Recordset

rsCari.Open "Select * from tHasil order by ID asc", CN, 1, 2 If Not rsCari.EOF Then

bolAda = True Else

bolAda = False

MsgBox "Data tidak ada" End If

Set rsCari = Nothing

End Sub

Private Sub Form_Unload(Cancel As Integer) Unload Me

Referensi

Dokumen terkait

Sebab ada tiga yang memberi kesaksian (di dalam sorga: Bapa, Firman dan Roh Kudus; dan ketiganya adalah satu. Dan ada tiga yang memberi kesaksian di bumi): Roh dan air dan darah

Kata kunci: Perkawinan, Adat Jawa,dan Muharram. Penelitian ini terfokus pada masyarakat yang menjalankan tradisi larangan menikah pada bulan Muharram. Adapun fokus penelitian

Serotipe ini memiliki struktur filogentik yang berbeda, menghasilkan rangkaian antibodi yang khas, dan titer virus 4 kali lebih tinggi pada infeksi sekunder

Jenis tanah ini berasal dari bahan induk organik seperti dari hutan rawa atau rumput rawa, dengan ciri dan sifat: tidak terjadi deferensiasi horizon secara jelas, ketebalan lebih

Hasil penelitian setelah dilakukan mandi dengan air hangat terhadap kualitas tidur lansia pada kelompok eksperimen, tingkat kualitas tidur lansia terlihat menurun,

Kegiatan penelitian mendukung pengembangan ilmu serta terapannya. Dalarn ha1 ini, Lembaga Penelitian Universitas Negeri Padang berusaha mendorong dosen untuk melakukan

Ikatan kovalen terjadi karena adanya penggunaan elektron secara bersama dari atom yang satu ke atom yang lainnya. Ikatan logam, interaksi terjadi karena adanya

Hasil penelitian adalah sebagai berikut; (1) bahwa gaya kepemimpinan situasional kepala sekolah berpengaruh positif terhadap komitmen organisasi guru di SMK Pasundan 1 Kota