首页>代码>java swing编写图片相似度处理识别技术代码>/图像对比/src/Demo/ImageComparer.java
package Demo;

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;
	}
	
	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;
	}

}
最近下载更多
xingxing1234  LV10 2023年3月22日
公共分类  LV1 2022年10月18日
kgq_kong  LV1 2022年8月31日
zinshao  LV12 2022年7月20日
微信网友_5992582549164032  LV6 2022年6月29日
wdm0408  LV1 2022年2月22日
.rabbit  LV1 2021年12月2日
xierongsong  LV1 2021年10月25日
1005948011  LV7 2021年5月10日
warhorse  LV1 2021年4月8日
最近浏览更多
晨爽明宇  LV1 3月4日
骆红亮 2月29日
暂无贡献等级
xingxing1234  LV10 2023年3月22日
hadesxxx 2022年12月10日
暂无贡献等级
arkic1 2022年12月1日
暂无贡献等级
公共分类  LV1 2022年10月18日
kgq_kong  LV1 2022年8月31日
chp123456 2022年7月26日
暂无贡献等级
zinshao  LV12 2022年7月20日
微信网友_5992582549164032  LV6 2022年6月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友