zoukankan      html  css  js  c++  java
  • 图像处理之基础---很好的一个快速比较两副图片是否相同的code 可用于公安鉴别

    转自Codeproject 

    http://www.codeproject.com/dotnet/comparingimages.asp

        Public Enum CompareResult

            ciCompareOk

            ciPixelMismatch

            ciSizeMismatch

        End Enum

     

     

        Public Shared Function Compare(ByVal bmp1 As Bitmap, ByVal bmp2 As Bitmap) As CompareResult

     

            '首先检查两副图片大小是否完全相等

            If Not bmp1.Size.Equals(bmp2.Size) Then

                Return CompareResult.ciSizeMismatch

            Else

                '把每个图片转成一字节数组

                Dim ic As New System.Drawing.ImageConverter

                Dim btImage1(1) As Byte

                btImage1 = CType(ic.ConvertTo(bmp1, btImage1.GetType()), Byte())

                Dim btImage2(1) As Byte

                btImage2 = CType(ic.ConvertTo(bmp2, btImage2.GetType()), Byte())

                Debug.WriteLine(UBound(btImage1))

                '计算每个图片的hash值

                Dim shaM As New SHA256Managed

     

                Dim hash1 As Byte() = shaM.ComputeHash(btImage1)

                Dim hash2 As Byte() = shaM.ComputeHash(btImage2)

     

                '比较hash值

                Dim i As Integer

                For i = 0 To Math.Min(hash1.Length, hash2.Length) - 1

                    If hash1(i) <> hash2(i) Then

                        Return CompareResult.ciPixelMismatch

                    End If

                Next

            End If

            Return CompareResult.ciCompareOk

        End Function

     

    http://blog.csdn.net/laviewpbt/article/details/754653

  • 相关阅读:
    poj 2262 筛法求素数(巧妙利用数组下标!)
    BestCoder Round #65 (ZYB's Premutation)
    BestCoder Round #65 (ZYB's Game)
    BestCoder Round #65 (ZYB's Biology)
    筛法求素数
    常见OJ提交结果对照表
    CSS3伸缩盒Flexible Box
    移动开发屏幕适配分析
    用PHP抓取页面并分析
    安装最新版本的PHPUnit后,不能使用
  • 原文地址:https://www.cnblogs.com/pengkunfan/p/4029457.html
Copyright © 2011-2022 走看看