Clear Filters
Clear Filters

Similarity between two matrices of different sizes

12 views (last 30 days)
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

Answers (3)

Dustin
Dustin on 29 Jul 2011
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 on 29 Jul 2011
%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 on 29 Jul 2011

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!