This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.app; | |
import android.graphics.*; | |
import android.util.Log; | |
/* | |
* pHash-like image hash. | |
* Author: Elliot Shepherd (elliot@jarofworms.com | |
* Based On: http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class pHash { | |
/** | |
* pHash算法流程 | |
* 1.缩小图片,最佳大小为32*32 | |
* 2.转化成灰度图 | |
* 3.转化为DCT图 | |
* 4.取dct图左上角8*8的范围 | |
* 5.计算所有点的平均值 | |
* 6.8*8的范围刚好64个点,计算出64位的图片指纹,如果小于平均值记为0,反之记为1,指纹顺序可以随机,但是每张图片的指纹的顺序应该保持一致 |