user3821689
user3821689

Reputation: 11

Image sort with matlab

I am trying to do some kind of image sorting.

I have 5 images and first one is my main image. I am trying to sort images according to their similarity.(Most similar image to less similar image).

Matlab had matchfeature method but I dont think I jave used it correctly because my results are wrong.I try to use:

[indexPairs,matchmetric] = matchFeatures(features1,features2,"MatchThreshold,10")

then i try to sort the matchmetric array.But it didnt work

Can anyone tell me some algorithm or any tips ?Thank you..

Upvotes: 1

Views: 920

Answers (3)

Dima
Dima

Reputation: 39419

Take a look at this example of image retrieval. Instead of matching the features between pairs of images it uses the KDTreeSearcher from the Statistics Toolbox to find nearest neighbors of each feature from the query image across the whole set of database images.

Upvotes: 0

chmod_007
chmod_007

Reputation: 378

You could compute the PSNR (peak signal-to-noise ratio) for each image compared to the main image. PSNR is a metric commonly used to measure the quality of a reconstructed compression against the original image.

It's implemented in Matlab in the Computer Vision System toolbox as a functional block, and there is also a psnr function in the Image Processing toolbox. The result will be a number in decibels you could use to rank the images. A higher PSNR value indicates greater similarity.

Upvotes: 1

Benoit_11
Benoit_11

Reputation: 13945

You could compute the correlation coefficient between every images and your main image and then sort them based on the coefficient.

doc corr2

For example, let's say you store all your images in a cell array (called ImageCellArray) in which the first image is your "main image":

for i = 2:size(ImageCellArray,2) % size(ImageCellArray,2) is the total # of images, i.e. the size of the cell array containing them.

CorrCoeff(i) = corr2(rgb2gray(ImageCellArray{1}),rgb2gray(ImageCellArray{i}));

end

[values indices] = sort(CorrCoeff); % sort the coefficients and get the number of the corresponging image.

Then you're good to go I guess.

Upvotes: 1

Related Questions