Similarity between two matrices of different sizes

12 次查看(过去 30 天)
Dear all,
I have two matrices(or images) of different sizes. Now i want to compare these two matrices and find out the maximum similarity between the matrices. The output should contain the points of similarity between them. Is these any way to do it in matlab using any function or toolbox or kindly some way to write the code ..
Thank you Gurunath

回答(3 个)

Dustin
Dustin 2011-7-29
I assume that by similarity you are referring to elements having the same values in the same locations. In that case, I suggest subtracting the two matrices, and finding the elements which are zero. I doubt that this approach will help you find similar regions in images though.

Paulo Silva
Paulo Silva 2011-7-29
%two random arrays with variable size and data
a=randi([1 10],randi([1 10]),randi([1 10]));
b=randi([1 10],randi([1 10]),randi([1 10]));
%find the common dimensions
mxr=min(size(a,1),size(b,1))
mxc=min(size(a,2),size(b,2))
%compare the values
a(1:mxr,1:mxc)==b(1:mxr,1:mxc)
you get the answer in one array with logic values, 1 when the values at same index are equal and 0 if they are not equal

Walter Roberson
Walter Roberson 2011-7-29

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by