我正在使用 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;
}
那么如何通过比较每个块中的平均位数来改进它
提前致谢