Similarity index beetween different size images

7 views (last 30 days)
Hi there; I'm looking for a Similarity Index (possibily in [0,1] range) beetween two images of different sizes. I've lookex for corr2, but it wants same size images. Also I've looked for xcorr2, but I don't understand how I could use it to get a similarity index.
Any help?

Accepted Answer

Massimo Zanetti
Massimo Zanetti on 9 Oct 2016
One idea can be appying a transform that reduce the bigger image into an image of the same size of the smaller one. Then apply any similarity index that works with same sized images.
  3 Comments
Massimo Zanetti
Massimo Zanetti on 9 Oct 2016
Edited: Massimo Zanetti on 9 Oct 2016
No! There is a very appropriate function to resize images: http://it.mathworks.com/help/images/ref/imresize.html
By default it uses bicubic interpolation, but you have also other options.
If this answer helped you, please accept it.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 9 Oct 2016
You can use ssim(), psnr, or immse():
image2 = imresize(image2, size(image1));
ssimval = ssim(image1, image2);
  3 Comments
nor azam
nor azam on 31 Oct 2019
Hi Image Analyst,
i got the same error when i used the given code which the size need to be same.
ref = imread('alif.jpg');
A = rgb2gray(ref);
BW1 = imbinarize(A);
figure
imshow(BW1)
image = imread('alif1.jpg');
B = rgb2gray(image);
BW2 = imbinarize(B);
figure
imshow(BW2)
%to calculate the percentage of similarity between ref and new image
BW2 = imresize(BW2, size(BW1));
ssimval = ssim(BW1, BW2);
This is my code. i already converted the images into binary and i want to find the percentage of similarity between two different size of image. please help me sir.
Mohammad Farhad Aryan
Mohammad Farhad Aryan on 29 Jan 2020
Input arguments of ssim() are expected to be one of these types: uint8, uint16, single or double not logical.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!