通过 Alheistogram 比较两个图像
A comparison between the two images by Alheistogram
我的项目是关于图片的查询,我是你先通过每张图片比较两张图片直方图如果alike given by presents to me that picture is similar, but the problem whenever he 告诉我输入两个不一样
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
为了直接与 ==
运算符进行比较,图像必须是相同的图像。如果您想这样做,只要检查 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
请注意,这都是推测,根本没有经过测试,可能有更好的方法。
我的项目是关于图片的查询,我是你先通过每张图片比较两张图片直方图如果alike given by presents to me that picture is similar, but the problem whenever he 告诉我输入两个不一样
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
为了直接与 ==
运算符进行比较,图像必须是相同的图像。如果您想这样做,只要检查 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
请注意,这都是推测,根本没有经过测试,可能有更好的方法。