⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 一个用vb编写指纹识别程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
Dim pixcolor() As Byte
Dim newcolor() As Integer
Dim light() As Integer
Dim color() As RGBQUAD
Dim num As Byte

Private Sub Form_Load()
Form1.Hide
Form2.Show
Form2.SetFocus
End Sub

Private Sub Command1_Click()
Form4.Show
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command10.Enabled = False
End Sub

Private Sub Command2_Click()
Form1.Hide
frmSplash.Show
frmSplash.SetFocus
End Sub

Private Sub Command9_Click()
Form5.Show
Form5.SetFocus
Dim Counter As Integer
Form5.ProgressBar1.Min = 0
Form5.ProgressBar1.max = 12000
Form5.ProgressBar1.Visible = True
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
For Counter = 0 To 12000
Form5.ProgressBar1.Value = Counter
Next Counter
Form5.ProgressBar1.Visible = False
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
Form5.Hide
Dim i, j, n, t As Integer
Form1.MousePointer = 11
Form1.Enabled = False
Open Form4.Text1.Text For Binary As #1
Get #1, , header
Get #1, , info
ReDim pixcolor(info.biHeight, info.biWidth, 2) As Byte
Select Case info.biBitCount
 
 Case 1
   ReDim color(2) As RGBQUAD
   Get #1, , color(0)
   Get #1, , color(1)
   For i = 0 To info.biHeight - 1
     For j = 0 To info.biWidth - 1
      Get #1, , num
      pixcolor(i, j, 0) = color(num).rgbBlue
      pixcolor(i, j, 1) = color(num).rgbGreen
      pixcolor(i, j, 2) = color(num).rgbRed
     Next j
   Next i
 
 Case 4
   ReDim color(16) As RGBQUAD
   For n = 0 To 15
     Get #1, , color(n)
   Next n
   For i = 0 To info.biHeight - 1
     For j = 0 To info.biWidth - 1
       Get #1, , num
       pixcolor(i, j, 0) = color(num).rgbBlue
       pixcolor(i, j, 1) = color(num).rgbGreen
       pixcolor(i, j, 2) = color(num).rgbRed
     Next j
   Next i
   
 Case 8
   ReDim color(255) As RGBQUAD
   For n = 0 To 255
     Get #1, , color(n)
   Next n
   If info.biWidth Mod 4 = 0 Then
     n = 0
   Else
     n = info.biWidth Mod 4
   End If
   
   For i = 0 To info.biHeight - 1
     For j = 0 To info.biWidth - 1
       Get #1, , num
       pixcolor(i, j, 0) = color(num).rgbBlue
       pixcolor(i, j, 1) = color(num).rgbGreen
       pixcolor(i, j, 2) = color(num).rgbRed
     Next j
   For t = 1 To n
     Get #1, , num
   Next t
   Next i
   
 Case 24
   If info.biWidth Mod 4 = 0 Then
     n = 0
   Else
     n = info.biWidth Mod 4
   End If
   
   For i = 0 To info.biHeight - 1
     For j = 0 To info.biWidth - 1
       Get #1, , pixcolor(i, j, 0)
       Get #1, , pixcolor(i, j, 1)
       Get #1, , pixcolor(i, j, 2)
     Next j
   For t = 1 To n
     Get #1, , num
   Next t
   Next i
End Select
Close #1

Form1.Enabled = True
Form1.MousePointer = 0
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True

End Sub

Private Sub Command10_Click()
Form5.Show
Form5.SetFocus
Dim Counter As Integer
Form5.ProgressBar1.Min = 0
Form5.ProgressBar1.max = 12000
Form5.ProgressBar1.Visible = True
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
For Counter = 0 To 12000
Form5.ProgressBar1.Value = Counter
Next Counter
Form5.ProgressBar1.Visible = False
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
Form5.Hide
Form3.Size = header.bfSize
Form3.ImgHeight = info.biHeight
Form3.ImgWidth = info.biWidth
Form3.Colors = 2 ^ info.biBitCount
Form3.Show
End Sub

Private Sub Command5_Click()

Dim i, j, yu As Integer
Dim r, g, b, hui, c As Long
Dim HeiBai(0 To 255, 0 To 255) As Integer
yu = 210
For i = 0 To Picture1.ScaleWidth - 1
  For j = 0 To Picture1.ScaleHeight - 1
    'For k = 0 To 2
    c = Picture1.Point(i, j)
    r = (c And &HFF)
    g = (c And 65280) / 256
    b = (c And &HFF0000) / 65536
'r = imageln(Red, i, j)
'g = imageln(Green, i, j)
'b = imageln(Blue, i, j)
hui = Fix((r + g + b) / 3)
If hui < yu Then
'hui = 0
Picture3.PSet (i, j), RGB(0, 0, 0)
HeiBai(i, j) = 0
Else
  'hui = 255
  Picture3.PSet (i, j), RGB(255, 255, 255)
  HeiBai(i, j) = 255
End If
'imageout(Red, i, j) = r
'imageout(Green, i, j) = g
'imageout(Blue, i, j) = b
Next
Next
End Sub

Private Sub Command4_Click()

Dim i As Integer
Dim j As Integer
Dim c, c1, c2, c3, c4, c5, c6, c7, c8, c9 As Long
Dim r, r1, r2, r3, r4, r5, r6, r7, r8, r9 As Long
Dim g As Long
Dim b As Long
Dim rr  As Integer
Dim gg, g2 As Integer
Dim bb, b2 As Integer
Dim fx, fy As Long
Picture2.Cls
Screen.MousePointer = 11
For i = 0 To Picture1.ScaleWidth - 1 - 1
For j = 0 To Picture1.ScaleHeight - 1 - 1
c1 = Picture1.Point(i, j - 1)
c2 = Picture1.Point(i - 1, j)
c3 = Picture1.Point(i, j)
c4 = Picture1.Point(i + 1, j)
c5 = Picture1.Point(i, j + 1)
c6 = Picture1.Point(i - 1, j - 1)
c7 = Picture1.Point(i - 1, j + 1)
c8 = Picture1.Point(i + 1, j - 1)
c9 = Picture1.Point(i + 1, j + 1)
r1 = (c1 And &HFF): r6 = (c6 And &HFF)
r2 = (c2 And &HFF): r7 = (c7 And &HFF)
r3 = (c3 And &HFF): r8 = (c8 And &HFF)
r4 = (c4 And &HFF): r9 = (c9 And &HFF)
r5 = (c5 And &HFF)
fx = r6 - r2 - r4 - r9 - r1 - r8 - r7 - r5 + 8 * r3
rr = Fix(Abs(fx / 2))
Picture2.PSet (i, j), RGB(rr, rr, rr)
Next j
'Picture2.Refresh
Next i
Screen.MousePointer = 0
End Sub

Private Sub Command3_Click()
Dim pic(1000, 1000), l As Double
Dim i, j, k, c, cc, r, g, b As Integer
'Dim yres As Integer
Dim picturename As String
Dim hd(255) As Long
MSChart1.ColumnCount = 33
MSChart1.RowCount = 8
Form1.MSChart1.Row = 1: Form1.MSChart1.RowLabel = "32"
Form1.MSChart1.Row = 2: Form1.MSChart1.RowLabel = "64"
Form1.MSChart1.Row = 3: Form1.MSChart1.RowLabel = "96"
Form1.MSChart1.Row = 4: Form1.MSChart1.RowLabel = "128"
Form1.MSChart1.Row = 5: Form1.MSChart1.RowLabel = "160"
Form1.MSChart1.Row = 6: Form1.MSChart1.RowLabel = "192"
Form1.MSChart1.Row = 7: Form1.MSChart1.RowLabel = "224"
Form1.MSChart1.Row = 8: Form1.MSChart1.RowLabel = "256"
Screen.MousePointer = 9
'读入图象数据存入数组
For i = 0 To Picture1.ScaleWidth - 1
  For j = 0 To Picture1.ScaleHeight - 1
    'For k = 0 To 2
    c = Picture1.Point(i, j)
    r = (c And &HFF)
    g = (c And 65280) / 256
    b = (c And &HFF0000) / 65536
    
    cc = Fix((r + g + b) / 3)
    pic(i, j) = cc
    'Next
  Next
Next
For i = 0 To Picture1.ScaleWidth - 1
  For j = 0 To Picture1.ScaleHeight - 1
  l = pic(i, j)
  hd(l) = hd(l) + 1
  Next
Next
For i = 0 To 7
Form1.MSChart1.Row = i + 1
For j = 0 To 31
Form1.MSChart1.Column = j + 1
Form1.MSChart1.Data = hd(i * 32 + j)
Next
Next
Screen.MousePointer = 0
End Sub

Public Sub picpoint()
Dim i As Integer, j As Integer
Dim k As Integer
Dim h(0 To 400, 0 To 400) As Integer
'存储像素的灰度值
Dim r As Integer
Dim c As Long
Dim hd(0 To 300) As Integer
Dim p(0 To 300) As Currency
'灰度均值
Dim tt(0 To 300) As Long
'存储个等级像素个数
Dim u As Long
Dim uu(0 To 300) As Long
Dim w(0 To 300) As Currency
Dim b(0 To 300) As Long
Dim max As Long
Dim maxb As Integer
Dim t As Integer
MousePointer = 11
'扫描全图,取得个像素灰度值
For i = 1 To Picture1.ScaleWidth
For j = 1 To Picture1.ScaleHeight
c = Picture1.Point(i, j)
r = (c And &HFF)
h(i, j) = r
Next
Next
'计算个级别像素个数
For i = 1 To Picture1.ScaleWidth
For j = 1 To Picture1.ScaleHeight
For r = 0 To 255
If h(i, j) = r Then
tt(r) = tt(r) + 1
End If
Next
Next
Next
For t = 0 To 255
p(t) = tt(t) / (Picture1.ScaleWidth * Picture1.ScaleHeight)
'计算灰度均值
Next
For t = 1 To 255
u = u + (t - 1) * p(t)
'计算灰度类均值和类直方图
Next
For k = 1 To 255
uu(k) = uu(k - 1) + (k - 1) * p(k)
'计算类分离指标
w(k) = w(k - 1) + p(k)
If w(k) * (1 - w(k)) <> 0 Then
b(k) = ((u * w(k) - uu(k)) * (u * w(k) - uu(k))) / (w(k) * (1 - w(k)))
End If
Next
max = b(0)
For k = 0 To 255
'求最大Q时的k
If b(k) >= max Then
max = b(k)
End If
Next
For k = 0 To 255
If b(k) = max Then
maxb = k
End If
Next
Label2.Caption = maxb - 1
'输出
End Sub

Private Sub Command8_Click()
picpoint
MousePointer = 0
End Sub

Private Sub Command6_Click()
CommonDialog1.ShowOpen
Picture4.Picture = LoadPicture(CommonDialog1.FileName)
End Sub

Private Sub Command11_Click()
Form5.Show
Form5.SetFocus
Dim Counter As Integer
Form5.ProgressBar1.Min = 0
Form5.ProgressBar1.max = 12000
Form5.ProgressBar1.Visible = True
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
For Counter = 0 To 12000
Form5.ProgressBar1.Value = Counter
Next Counter
Form5.ProgressBar1.Visible = False
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
Form5.Hide
Dim count1, i, j As Integer
Dim HeiBai(0 To 255, 0 To 255) As Integer
Form1.Label4.Caption = 0
For i = 0 To Picture3.ScaleWidth - 1
  For j = 0 To Picture3.ScaleHeight - 1
    If HeiBai(i, j) = 0 Then
      count1 = count1 + 1
   End If
    Next
Next
Form1.Label4.Caption = Fix(count1 / 389)
End Sub
Private Sub Command7_Click()
Form5.Show
Form5.SetFocus
Dim Counter As Integer
Form5.ProgressBar1.Min = 0
Form5.ProgressBar1.max = 12000
Form5.ProgressBar1.Visible = True
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
For Counter = 0 To 12000
Form5.ProgressBar1.Value = Counter
Next Counter
Form5.ProgressBar1.Visible = False
Form5.ProgressBar1.Value = Form5.ProgressBar1.Min
Form5.Hide
Dim i As Integer
If Label2.Caption = 212 And Label4.Caption = 107 Then
  MsgBox "验证成功!", 0 + vbInformation, "分析结果"
Else
  i = MsgBox("验证失败!", 5 + vbExclamation, "分析结果")
  If i <> 4 Then
    End
  End If
End If
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -