MATLAB: Measure Line Segment Length Cross One Fixed Point

image analysisimage processingImage Processing Toolbox

I'd like to measure the shortest distance between two dark portion. The distance line segment should cross the red point on the image. The black and white background are logical values. The background matrix and the red point are known (attached as data.mat). I tried polyxpoly() but failed to use it. Any ideas? Thanks!

Best Answer

I already answered something very similar to this from you recently.
Why don't you try bwdist(). It will find the distance of every point to the closest background point. If you really need the distance that is not the shortest, but along some arbitrary line you draw, then you'll have to use improfile().