how to find euclidean distance for an image
Ältere Kommentare anzeigen
I have 100 images and i have to find the euclidean distance for it,and i have to take a query image and find the euclidean distance and retrieve the image ,i have extracted an feature of an image and have stored it in .mat file,please help
5 Kommentare
Naz
am 22 Dez. 2011
Amazing. You have such diverse questions. I wonder how you manage to work on so many different things at a time.
Joel
am 13 Mär. 2013
Dear FIR, could you please send me the files to this project so I can have a better look and see if I might be able to help.
Thanks
Image Analyst
am 13 Mär. 2013
Joel, did you notice that FIR posted this 15 months ago? I doubt he still needs your help on it. Besides, he accepted an answer already.
Min Min
am 17 Okt. 2020
Can I use this formula to the find histogram similarity value "1-norm(y1-y0)/norm(y0)" which is used in image steganography
Image Analyst
am 17 Okt. 2020
I have no idea.
Akzeptierte Antwort
Weitere Antworten (5)
Junaid
am 21 Dez. 2011
1 Stimme
Dear FIR,
Similar question was asked by one fellow. The solution you can see from following URL. I hope it might help you.
6 Kommentare
FIR
am 21 Dez. 2011
Junaid
am 22 Dez. 2011
Dear FIR,
Sorry FIR I can't overview your code you sent to me. To compute the Euclidean distance between images or image features, your vector length or matrix should have same dimensions. Let say your first image has 1 x 460 vector then your query should be of same length. If that is the case then you can easily find Euclidean distance by the code I have written below. You just have to ensure that the dimensions are the same. I give you example of Histogram feature of image.
I = imread('myimage.jpg');
I = rgb2gray(I);
h = imhist(I); % this will have default bins 256
% now second image
J = imread('myimage1.jpg');
J = rgb2gray(J);
h1 = imhist(J); % this will have default bins 256
E_distance = sqrt(sum((h-h1).^2));
You can do it for 1000 images as well.
sandeep kumar kailasa
am 12 Feb. 2017
How to get it for 10 images
Image Analyst
am 12 Feb. 2017
Sandeep, two code snippets for processing a sequence of files are in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
suma g
am 8 Feb. 2018
sir, how to calculate the distance only for particular feature say left eye and right eye
Image Analyst
am 8 Feb. 2018
You'd use the sqrt() function for that (calculating distance), once you have their coordinates.
Junaid
am 21 Dez. 2011
Dear Fir,
You have Query image Q, you want to compute euclidean distance of Q with all images in database. Is that you want ? If yes then Let say query Image Q is grayscale image so you can present it as feature vector
Q = Q(:); % this is one [size(Q,1) x size(Q,2) by 1]
all the images in database should have same dimensions. Let say every image and query image should have same number of pixels.
Now you load your database
D = load('Database.mat');
we assume that each column is one image and your number of columns should be size of Database. or if you want to present each row as image then simply take the transpose.
Q= repmat(Q,1,size(D,2));
E_distance = sqrt(sum((Q-D).^2));
Now E_distance have euclidean distance of Q with all images in database D.
Do let me know if It solved your problem.
3 Kommentare
Image Analyst
am 21 Dez. 2011
He said "I have extracted features of 100 images and stored in .matfile.i have to find euclidean distance for those" so he wants to compare feature vectors, not the images themselves. Anyway trying to compare images on a pixel by pixel basis is only useful for certain kinds of situations, like characterizing compression/decompression algorithms, not, say for retrieving all images from a huge database that have faces in them.
FIR
am 21 Dez. 2011
FIR
am 22 Dez. 2011
Sean de Wolski
am 20 Dez. 2011
doc bwdist
doc graydist
might be some places to start.
1 Kommentar
FIR
am 21 Dez. 2011
Image Analyst
am 21 Dez. 2011
0 Stimmen
The Euclidean distance is another image. What do you mean "query image by Euclidean distance"? I don't even know what that means. Please explain.
6 Kommentare
FIR
am 21 Dez. 2011
Image Analyst
am 21 Dez. 2011
That's not when you'd use bwdist(). You simply need to use the Pythagorean theorem on your feature vectors:
generalizedDistance = sqrt(mean((featureVector1 - featureVector2)^2));
Weight the various features (elements) if you want to or need to. This will compare the feature vectors of two images. Then compare the feature vector of your reference image to the feature vector of all other images (by calculating generalizedDistance ) to see which image has a feature vector closest to the feature vector of your reference image.
FIR
am 21 Dez. 2011
Image Analyst
am 21 Dez. 2011
I don't understand that. What is that? Is your feature vector actually a cell array where the first cell has a 487 element row vector, same for the second cell, the third cell has a 359 element row vector, etc. Do you have 100 cells in your cell array? Feature vectors virtually never have thousands of features in them like that. I think you've chosen the wrong features. What does each feature represent? They should be things like the mean, standard deviation (for each color), perhaps the area fraction of edges or of "skin" pixels, maybe the presence of certain shapes, etc. Here's a nice database comparison that gets color feature vectors and retrieves images with those colors you select in it:
http://labs.ideeinc.com/multicolr/
FIR
am 21 Dez. 2011
Image Analyst
am 21 Dez. 2011
I probably won't get to it. I'm leaving on 9 day vacation to Florida in a couple of hours.
shradha naik
am 8 Feb. 2017
0 Stimmen
hi.. i needed some help regarding implementing quadtree decomposition and histogram based image retrieval i wanted to apply quadtree on an image and then on the segmented image histogram needs to be computed can u please help me out??
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!