how to find euclidean distance for an image

조회 수: 20 (최근 30일)
FIR
FIR 2011년 12월 20일
댓글: Image Analyst 2020년 10월 17일
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
Min Min
Min Min 2020년 10월 17일
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
Image Analyst 2020년 10월 17일
I have no idea.

댓글을 달려면 로그인하십시오.

채택된 답변

Junaid
Junaid 2011년 12월 22일
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 two images.
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. Let say now your 1000 images histogram are concatenated into h1. where each column is one histogram. Then your query image histogram is h. Then distance can be computed as follow.
h_new = repmat(h,1,size(h1,2));
E_distance = sqrt(sum((h_new-h1).^2));
  댓글 수: 2
Aziz
Aziz 2012년 10월 3일
nice share Junaid... can i ask question similar to this one... i also have problem to compare 2 image at onetime, example of 2 simple image... http://i50.tinypic.com/259e5hh.jpg http://i47.tinypic.com/21m6q9c.jpg
so it is possible to get the x and y axis value for this difference?
jenifer
jenifer 2012년 10월 29일
I also have one doubt related to this..I want to classify normal and abnormal images..I m having histogram as a features for normal and abnormal images.. How can i compute the feature vectors for these histograms...

댓글을 달려면 로그인하십시오.

추가 답변 (5개)

Junaid
Junaid 2011년 12월 21일
Dear FIR,
Similar question was asked by one fellow. The solution you can see from following URL. I hope it might help you.
  댓글 수: 6
suma g
suma g 2018년 2월 8일
sir, how to calculate the distance only for particular feature say left eye and right eye
Image Analyst
Image Analyst 2018년 2월 8일
You'd use the sqrt() function for that (calculating distance), once you have their coordinates.

댓글을 달려면 로그인하십시오.


Junaid
Junaid 2011년 12월 21일
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
FIR
FIR 2011년 12월 21일
Juniard i have uploaded my files,plz look it and suggest ideas
I have attached my program files plz see it and give suggestion
http://www.sendspace.com/file/t58trj
FIR
FIR 2011년 12월 22일
Juniard i get error wen executing ur code
Undefined function or method 'minus' for input arguments of type 'struct'.
Error in ==> features at 22
E_distance = sqrt(sum((Q-D).^2))

댓글을 달려면 로그인하십시오.


Sean de Wolski
Sean de Wolski 2011년 12월 20일
doc bwdist
doc graydist
might be some places to start.
  댓글 수: 1
FIR
FIR 2011년 12월 21일
Sean can u tell how to process for image retrieval using query image by euclidean distance

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2011년 12월 21일
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
FIR
FIR 2011년 12월 21일
I have attached my program files plz see it and give suggestion
http://www.sendspace.com/file/t58trj
Image Analyst
Image Analyst 2011년 12월 21일
I probably won't get to it. I'm leaving on 9 day vacation to Florida in a couple of hours.

댓글을 달려면 로그인하십시오.


shradha naik
shradha naik 2017년 2월 8일
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??

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by