i want to calculate the perpendicular distance between one point on line (A) and another on line B

2 views (last 30 days)
I want to be able to find the maximum and minimum distance in the given image that I worked on using a couple of filters and got it's boundaries using bwboundaries(). I have the x and y positions of all the points. I also have the distance between two points on the same line.
Last thing . . . is there a way to show the perpendicular line that is being measured between the two points?
Thank you in advance

Accepted Answer

Image Analyst
Image Analyst on 8 Jun 2018
Sure. If you have the stats toolbox, simply use pdist2():
distances = pdist2(xy1, xy2);
  19 Comments
Image Analyst
Image Analyst on 9 Jun 2018
Not exactly sure what you want. Perhaps a diagram would help. If you turn the "in between" zone into a binary image then you can skeletonize it to get the centerline. You can then take the Euclidean Distance with bwdist(). Then multiply then to get the distance from the centerline to the closest edge. However, this distance is not the same distance as the distance perpendicular to the centerline in the general case. Just think of a funnel shape. The skeleton can be though of as the center point of the smallest disk that can be fit into the funnel and if the sides are not parallel, then the ball/disk will touch the sides at points that are not perpendicular to the center line.
mohammed radwan
mohammed radwan on 11 Jun 2018
ok finally im sure this code is correct it gets the maximum and minimum perpendicular distances
if true
% code
end
c=1;
cc=1;
for i=1:1:LL
woux2=axxai2(i);
wouy2=ayyai2(i);
for j=1:1:LL
woux1=arxxai(j);
wouy1=aryyai(j);
distance=pdist2([woux1 wouy1],[woux2 wouy2],'euclidean','Smallest',10);
p(j)=distance;
end
qq(c)=min(p);
qqq(cc)=max(p);
c=c+1;
cc=cc+1;
end

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!