# Find the actual distances in an image.

3 views (last 30 days)

Show older comments

### Accepted Answer

Mohammad Abouali
on 15 Apr 2016

Similar approach to this should work:

I=imread('P3290337.JPG');

I=padarray(I,[1 1 0],0);

thresh = 15;

mask = ~(I(:,:,1) < thresh & I(:,:,2) < thresh & I(:,:,1) < thresh);

xProj = any(mask);

xMin = find(xProj,1,'first')-0.5;

xMax = find(xProj,1,'last');

yProj = any(mask,2);

yMin = find(yProj,1,'first');

yMax = find(yProj,1,'last');

imshow(I);

hold on

plot([xMin xMin],ylim,'r','LineWidth',2)

plot([xMax xMax],ylim,'r','LineWidth',2)

plot(xlim,[yMin yMin],'r','LineWidth',2)

plot(xlim,[yMax yMax],'r','LineWidth',2)

### More Answers (1)

### See Also

### Community Treasure Hunt

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

Start Hunting!