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

  • 相关阅读:
    调试PHP如何让浏览器提示错误
    接口的理解
    linux中的curl
    linux后台执行命令:&和nohup
    php定界符<<<EOF讲解
    有关字符集问题
    设置disabled属性
    PHP魔术常量
    phpstorm-有关设置
    php常用函数
  • 原文地址:https://www.cnblogs.com/pengkunfan/p/4029457.html
Copyright © 2011-2022 走看看