{"rsdb":{"rid":"376854","subhead":"","postdate":"0","aid":"263785","fid":"86","uid":"1","topic":"1","content":"
\n

Hash\u7b97\u6cd5\u6709\u4e09\u79cd\uff0c\u5206\u522b\u4e3a\u5e73\u5747\u54c8\u5e0c\u7b97\u6cd5(aHash)\u3001\u611f\u77e5\u54c8\u5e0c\u7b97\u6cd5\u4f60(pHash)\u548c\u5dee\u5f02\u54c8\u54c8\u5e0c\u7b97\u6cd5(dHash)\u3002<\/p> \n

\u9488\u5bf9\u4ee5\u4e0a\u4e09\u79cd\u7684Hash\u7b97\u6cd5\u8be6\u89e3\u89c1\u535a\u5ba2\u56ed\u6587\u7ae0 <\/p> \n

https:\/\/www.cnblogs.com\/Kalafinaian\/p\/11260808.html<\/p> \n

\u672c\u6587\u5b9e\u73b0\u9488\u5bf9\u5e73\u5747\u54c8\u5e0c\u7b97\u6cd5\uff1b<\/p> \n

1 \u5e73\u5747\u54c8\u5e0c\u7b97\u6cd5\uff08aHash\uff09<\/h1> \n

1.1 \u7b97\u6cd5\u6b65\u9aa4<\/h2> \n

       \u5e73\u5747\u54c8\u5e0c\u7b97\u6cd5\u662f\u4e09\u79cdHash\u7b97\u6cd5\u4e2d\u6700\u7b80\u5355\u7684\u4e00\u79cd\uff0c\u5b83\u901a\u8fc7\u4e0b\u9762\u51e0\u4e2a\u6b65\u9aa4\u6765\u83b7\u5f97\u56fe\u7247\u7684Hash\u503c\uff0c\u8fd9\u51e0\u4e2a\u6b65\u9aa4\u5206\u522b\u662f(1) \u7f29\u653e\u56fe\u7247\uff1b\uff082\uff09\u8f6c\u7070\u5ea6\u56fe; (3) \u7b97\u50cf\u7d20\u5747\u503c\uff1b\uff084\uff09\u6839\u636e\u76f8\u4f3c\u5747\u503c\u8ba1\u7b97\u6307\u7eb9\u3002\u5177\u4f53\u7b97\u6cd5\u5982\u4e0b\u6240\u793a:<\/p> \n

\u3000\u3000\u88681 aHash\u5f97\u5230\u56fe\u7247Hash\u503c\u5730\u7b97\u6cd5<\/p> \n \n \n \n \n \n \n

\u7f29\u653e\u56fe\u7247<\/p> <\/td> \n

\u8f93\u5165\u56fe\u7247\u5927\u5c0f\u5c3a\u5bf8\u5404\u5f02\uff0c\u4e3a\u4e86\u7edf\u4e00\u56fe\u7247\u7684\u8f93\u5165\uff0c\u7edf\u4e00\u5c06\u56fe\u7247\u5c3a\u5bf8\u7f29\u653e\u4e3a8*8\uff0c\u4e00\u5171\u5f97\u5230\u4e8664\u4e2a\u50cf\u7d20\u70b9\u3002<\/p> <\/td> \n <\/tr> \n

\u8f6c\u7070\u5ea6\u56fe<\/p> <\/td> \n

\u8f93\u5165\u56fe\u7247\u6709\u4e9b\u4e3a\u5355\u901a\u9053\u7070\u5ea6\u56fe\uff0c\u6709\u4e9bRGB\u4e09\u901a\u9053\u5f69\u8272\u56fe\uff0c\u6709\u4e9b\u4e3aRGBA\u56db\u901a\u9053\u5f69\u8272\u56fe\u3002\u4e5f\u4e3a\u4e86\u7edf\u4e00\u4e0b\u4e00\u6b65\u8f93\u5165\u6807\u51c6\uff0c\u5c06\u975e\u5355\u901a\u9053\u56fe\u7247\u90fd\u8f6c\u4e3a\u5355\u901a\u9053\u7070\u5ea6\u56fe\u3002 \u5176\u4e2dRGB\u4e09\u901a\u9053\u8f6c\u5355\u901a\u9053\u7b97\u6cd5\u6709\u4e0b\u9762\u51e0\u79cd:<\/p>

1.\u6d6e\u70b9\u7b97\u6cd5\uff1aGray=R0.3+G<\/em>0.59+B0.11<\/em><\/p>

2.\u6574\u6570\u65b9\u6cd5\uff1aGray=(R<\/em>30+G59+B<\/em>11)\/100<\/p>

3.\u79fb\u4f4d\u65b9\u6cd5\uff1aGray =(R76+G<\/em>151+B*28)>>8; <\/p>

4.\u5e73\u5747\u503c\u6cd5\uff1aGray=\uff08R+G+B\uff09\/3; <\/p>

5.\u4ec5\u53d6\u7eff\u8272\uff1aGray=G\uff1b<\/p> <\/td> \n <\/tr> \n

\u7b97\u50cf\u7d20\u5747\u503c<\/td> \n

\u901a\u8fc7\u4e0a\u4e00\u6b65\u53ef\u5f97\u4e00\u4e2a8x8\u7684\u6574\u6570\u77e9\u9635G\uff0c\u8ba1\u7b97\u8fd9\u4e2a\u77e9\u9635\u4e2d\u6240\u6709\u5143\u7d20\u7684\u5e73\u5747\u503c\uff0c\u5047\u8bbe\u5176\u503c\u4e3aa<\/p> <\/td> \n <\/tr> \n

\u636e\u50cf\u7d20\u5747\u503c\u8ba1\u7b97\u6307\u7eb9<\/p> <\/td> \n

\u521d\u59cb\u5316\u8f93\u5165\u56fe\u7247\u7684ahash = "" <\/p>

\u4ece\u5de6\u5230\u53f3\u4e00\u884c\u4e00\u884c\u5730\u904d\u5386\u77e9\u9635G\u6bcf\u4e00\u4e2a\u50cf\u7d20\u5982\u679c\u7b2ci\u884cj\u5217\u5143\u7d20G(i,j) >= a\uff0c\u5219ahash += "1"\u5982\u679c\u7b2ci\u884cj\u5217\u5143\u7d20G(i,j) <a\uff0c \u5219ahash += "0"<\/p> <\/td> \n <\/tr> \n <\/tbody> \n <\/table> \n

       <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

 <\/p> \n

\u5f97\u5230\u56fe\u7247\u7684ahash\u503c\u540e\uff0c\u6bd4\u8f83\u4e24\u5f20\u56fe\u7247ahash\u503c\u7684\u6c49\u660e\u8ddd\u79bb\uff0c\u901a\u5e38\u8ba4\u4e3a\u6c49\u660e\u8ddd\u79bb\u5c0f\u4e8e10\u7684\u4e00\u7ec4\u56fe\u7247\u4e3a\u76f8\u4f3c\u56fe\u7247\u3002<\/p> \n

  Demo \u754c\u9762\/  <\/p> \n

 \"\"<\/p> \n

   \"\"<\/p> \n

\"\"<\/p> \n

  \u83b7\u53d6aHash\u51fd\u6570\u5982\u4e0b\uff1a<\/p> \n

\n
function TForm1.GetHash(src: TBitmap; iType: Integer): Int64;\r\nvar\r\n  p: PByteArray;\r\n  bmp: TBitmap;\r\n  x, y: Integer;\r\n  gray, sum: Integer;\r\n  ct: array[0..7, 0..7] of Byte;\r\n  avg: Single;\r\n  ret: Int64;\r\nbegin\r\n  ret := 0;\r\n  case iType of\r\n    0:  \/\/ aHash  \u5e73\u5747\u54c8\u5e0c\u7b97\u6cd5\r\n    begin\r\n      bmp := TBitmap.Create;\r\n      try\r\n        bmp.Assign(src);\r\n        bmp.Width := 8;\r\n        bmp.Height := 8;\r\n        bmp.PixelFormat := pf24bit;\r\n        sum := 0;\r\n        for y := 0 to 7 do\r\n        begin\r\n          p := bmp.ScanLine[y];\r\n          for x := 0 to 7 do\r\n          begin\r\n            \/\/\u8f6c\u7070\u5ea6\u56fe \u5e73\u5747\u503c\u6cd5\r\n            gray := (p[3 * x + 2] + p[3 * x + 1] + p[3 * x]) div 3;\r\n            ct[y, x] := gray;\r\n            sum := sum + gray;\r\n          end;\r\n        end;\r\n        avg := sum\/64;\r\n        for y := 0 to 7 do\r\n          for x := 0 to 7 do\r\n            ret := ret shl 1 or Ord(ct[y, x] > avg);\r\n      finally\r\n        bmp.Free;\r\n      end;\r\n    end;\r\n    1:  \/\/ pHash  \u611f\u77e5\u54c8\u5e0c\u7b97\u6cd5\r\n    begin\r\n\r\n    end;\r\n    2:  \/\/ dHash  \u5dee\u5f02\u54c8\u5e0c\u7b97\u6cd5\r\n    begin\r\n\r\n    end;\r\n  end;\r\n  Result := ret;\r\nend;\r\n<\/pre> \n <\/div> \n 

\u8ba1\u7b97\u6c49\u660e\u8ddd\u79bb\u51fd\u6570\uff1a\u539f\u7406\u53c2\u8003\uff1ahttps:\/\/blog.csdn.net\/u013243347\/article\/details\/52220551<\/p> \n

\n
function TForm1.Hamming(Hash1, Hash2: Int64): Integer;\r\nvar\r\n  A: Int64;\r\nbegin\r\n  Result := 0;\r\n  A := Hash1 xor Hash2;\r\n  while A<>0 do\r\n  begin\r\n    A := A and (A-1);\r\n    Inc(Result);\r\n  end;\r\nend;\r\n<\/pre> \n <\/div> \n 

Demo \u4e0b\u8f7d\u5730\u5740\uff1ahttps:\/\/download.csdn.net\/download\/huffmanlepand\/11833317<\/p> \n<\/div>","orderid":"0","title":"\u56fe\u50cf\u7684\u76f8\u4f3c\u5ea6Hash\u7b97\u6cd5","smalltitle":"","mid":"0","fname":"Delphi","special_id":"0","bak_id":"0","info":"0","hits":"253","pages":"1","comments":"0","posttime":"2019-10-09 20:01:18","list":"1570622478","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u56fe\u50cf<\/A> \u76f8\u4f3c<\/A> Hash<\/A> \u7b97\u6cd5<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.32","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u56fe\u50cf\u7684\u76f8\u4f3c\u5ea6Hash\u7b97\u6cd5","lastview":"1713477696","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}