【问题标题】:A comparison between the two images by Alheistogram通过 Alheistogram 比较两幅图像
【发布时间】:2016-03-29 01:05:38
【问题描述】:

我的项目是一个关于图像的查询,我是你首先通过每个图像直方图在两个图像之间进行比较如果相同的人给我呈现给我的图片是相似的,但是问题每当他告诉我输入两个不是一样的

A=imread('C:\Users\saba\Desktop\images\q4.jpg');%reading images as array to variable 'a'&'b' 
B = imread('C:\Users\saba\Desktop\images\q1.jpg');
j=rgb2gray(A);
i=rgb2gray(B);
subplot(2,2,1);imshow(A);
subplot(2,2,2);imshow(B);
subplot(2,2,3);imshow(j);
subplot(2,2,4);imshow(i);

if  histeq(j)==histeq(i)
   disp('The images are same')%output display 
else 
   disp('the images are not same') 
end 

【问题讨论】:

  • q4 和 q1 是同一张图片吗?也许您需要找到相似度的度量而不是直方图的精确匹配?

标签: database matlab image-processing histogram


【解决方案1】:

为了直接与== 运算符进行比较,图像必须是相同的图像。如果你想这样做,你可以检查i==j,只要它们大小相同。

据我所知,没有内置函数或工具箱可以检查两个图像是否相似。您可以使用的一种粗略方法是查看每行和每列的像素值之和有多么不同:

maxColumnDifference = max(abs(sum(j, 1) - sum(i, 1)));
maxRowDifference = max(abs(sum(j, 2) - sum(i, 2)));

然后你可以有一些公差,总和必须在其中,应该是图像大小的函数。要给出行或列差异程度的标准化答案 (0-255),只需将每个总和除以像素数即可。

maxColumnDifference = max(abs(sum(j, 1)/size(j,1) - sum(i, 1)/size(i,1)));
maxRowDifference = max(abs(sum(j, 2)/size(j,2) - sum(i, 2)/size(i,2)));

然后您可以通过以下方式确定它们是否相似:

tolerance = 50;
if (maxRowDifference < tolerance) && (maxColumnDifference < tolerance)
    disp('Images are similarish');
else
    disp('Images are not similar enough for this poor tool to recognise');
end

请注意,这都是推测,根本没有经过测试,可能有更好的方法。

【讨论】:

    猜你喜欢
    • 2016-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 2012-09-26
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多