I want to find the euclidean distance of 1 specific feature in one image.Then the corresponding feature in the second image. How to find the euclidean distance of these two points? Any suggestions.

 채택된 답변

Image Analyst
Image Analyst 2014년 12월 3일

0 개 추천

I wouldn't use ginput() or pdist(). I'd use the function improfile() in the Image Processing Toolbox. It's a lot easier to use than imdistline(). Here's a snippet:
% Display sample image.
grayImage = imread('moon.tif');
imshow(grayImage);
title('Left click, then right click');
% Have user draw the line.
[x, y, grayLevels] = improfile();
% Re-Draw the line in the overlay (which normally vanishes)
line([x(1), x(end)], [y(1), y(end)]);
% Compute the distance between the endpoints.
dist = sqrt((x(end)-x(1))^2 + (y(end)-y(1))^2)

댓글 수: 4

Chathu
Chathu 2014년 12월 3일
Image Analyst- As you said,improfile() is much easier than pdist(). Thanks alot for your guidance.
Chathu
Chathu 2014년 12월 3일
Image Analyst- i have RGB images. improfile function still works for RGB images, correct?
Do i have to edit the below portion of your snippet? (eg: from grey to color) [x, y, grayLevels] = improfile();
Image Analyst
Image Analyst 2014년 12월 3일
It will still work, as is. You might want to rename variables to make them more accurately descriptive, like rgbImage instead of grayImage.
Chathu
Chathu 2014년 12월 4일
Alright. Thanks alot for the response.

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

추가 답변 (1개)

Deepesh B
Deepesh B 2014년 12월 2일

0 개 추천

use
dist_out = pdist(feature_array,'euclidean');
if u want to use b/w 2 images use this
dist_out = pdist2(i1, i2,'euclidean')

댓글 수: 1

Deepesh- thank you so much for your rapid response. I know the qu that i am going to ask now is quite simple. But i just want to clarify.
Suppose i said as follows: S=ginput(2)
Then the outcome is as follows: S =
157.4501 208.9473
402.7736 205.8420
My qu is: 1st row refers to (x1,y1) and 2nd row denotes (x2,y2). Is that correct?

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

질문:

2014년 12월 2일

댓글:

2014년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by