# Find the euclidean distance

1 view (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Image Analyst
on 3 Dec 2014

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 Comments

Image Analyst
on 3 Dec 2014

### More Answers (1)

Deepesh B
on 2 Dec 2014

use

dist_out = pdist(feature_array,'euclidean');

if u want to use b/w 2 images use this

dist_out = pdist2(i1, i2,'euclidean')

### See Also

### Categories

### Products

### Community Treasure Hunt

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

Start Hunting!