package com.image.compare;
import java.awt.image.BufferedImage;
public class ImageComparer {
private BufferedImage sourceImage;
private BufferedImage candidateImage;
public ImageComparer(BufferedImage srcImage, BufferedImage canImage) {
this.sourceImage = srcImage;
this.candidateImage = canImage;
}
/**
* Bhattacharyya Coefficient
* http://www.cse.yorku.ca/~kosta/CompVis_Notes/bhattacharyya.pdf
*
* @return
*/
public double modelMatch() {
HistogramFilter hfilter = new HistogramFilter();
float[] sourceData = hfilter.filter(sourceImage, null);
float[] candidateData = hfilter.filter(candidateImage, null);
double[] mixedData = new double[sourceData.length];
for (int i = 0; i < sourceData.length; i++) {
mixedData[i] = Math.sqrt(sourceData[i] * candidateData[i]);
}
// The values of Bhattacharyya Coefficient ranges from 0 to 1,
double similarity = 0;
for (int i = 0; i < mixedData.length; i++) {
similarity += mixedData[i];
}
// The degree of similarity
return similarity;
}
}
最近下载更多
微笑刺客 LV21
2024年5月30日
一头土猪 LV7
2021年12月22日
okliu123456 LV24
2021年12月14日
与你同行2019 LV11
2019年11月26日
LYXNAME LV1
2018年7月19日
马昌平 LV2
2018年3月16日
dagf113225 LV68
2018年3月12日
andinker LV10
2018年2月21日
Black_杰ck LV1
2017年12月25日
weizhi LV5
2017年12月4日
最近浏览更多
lipanlong LV10
2024年12月3日
sswert LV2
2024年9月12日
微笑刺客 LV21
2024年5月30日
liyonggang LV2
2024年1月19日
lvdong2023 LV10
2023年5月17日
13655961071 LV5
2023年5月4日
xuaniw LV4
2022年10月17日
微信网友_5992582549164032 LV6
2022年6月29日
ttppbb LV4
2022年6月29日
eddie2260 LV2
2022年6月17日

