【发布时间】:2012-12-03 18:39:58
【问题描述】:
我正在使用 OpenCV 库编写图像比较应用程序。我正在使用基本块匹配方法
如何提取每个块中的位数
认为这是一张图片
16x16 像素
--------------
+ +
+ +
+ +
+------------+
块大小 = 8x8 像素
--------------
+ | +
+------------+
+ | +
+------------+
我的程序:
1) 读取两张图片
2)将它们转换为灰度
3)将图像划分为块的数量
4)块比较
5)在输出中打印相似度百分比
我的函数比较图像中块的每个像素
float imCompBMA(float **b1, float **b2, float h, float w){
float percent;
int i, j, counter=0;
for(i=0;i<h;i++){
for(j=0;j<w;j++){
// If both blocks have the same value at pixel (i,j)
//this line has to be improved
if(b1[i][j]==b2[i][j]){
counter++;
}
}
}
// Percent is the number of same pixels to the total number of pixels
percent=(float)(counter/(h*w))*100;
return percent;
}
那么如何通过比较每个块中的平均位数来改进它
提前致谢
【问题讨论】:
-
每个块的平均位数是什么意思?每个块中的每个像素都有相同的位数。