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

image analysisimage processingStatistics and Machine Learning Toolbox

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

Best Answer

Sure. If you have the stats toolbox, simply use pdist2():
distances = pdist2(xy1, xy2);