Clear Filters
Clear Filters

Find the distance of a point from a line in an image.

1 view (last 30 days)
Hi
I'd like to request some help. I have an noisy image with its edges detected using Sobel. I need to take each line(edge) on the image and find the distance of all points on the image(edge detected image) from those lines. The trouble I am having, is figuring out how to find the distance of points from a line. How do I identify the line? Is there any function to find the equations of a line in an image?

Answers (1)

Roger Stafford
Roger Stafford on 2 Nov 2017
If A and B are coordinate vectors of two points on your line, and C is the vector of another point, the orthogonal distance of point C from the line AB is:
BA = B-A;
CA = C-A;
norm(CA-dot(CA,BA)/dot(BA,BA)*BA);

Products

Community Treasure Hunt

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

Start Hunting!