-1

I am working with image segmentation in Matlab.

I need to find a line perpendicular to a set of points in order to calculate the maximum distance between that line and the set of points.
Here's an example of the problem:

Example of image

The red point represents the concavity of the contour and that point was found from the curvature of the contour.

The black line and the green points, which are the limit of the line, were manually drawn to show the result that I am looking for.

After finding the line, the next task is to calculate the maximum distance between the line and the part of the contour highlighted in yellow.

Could anyone suggest a possible solution?

fantaghirocco
  • 4,761
  • 6
  • 38
  • 48
danilo
  • 1
  • 1
  • 1
    What is the set of points ??? And what is a line *perpendicular* to a set of points ??? –  Jul 27 '16 at 14:13

1 Answers1

1

To draw a line you just need to get the derivative of the function at that point, as you probably remember from basic algebra.

You can just do it with finite differences, but I suggest you use more than 2 points, say 5 or 7 to approximate the derivative at that point. Then drawing the line is as easy as

y-y0=f'(x) (x-x0)

where y0,x0 is the point itself. As you dont have a function representation of your contour, to compute the crossection of the line with the contour the best thing would be to numerically check it.

Additionally, you could create a binary image with the contour and everything inside of it and then use improfile with points in the line but outside the white blob. As the value is equal to one, the integral of the line over the path would be the total length of the line inside the contour.

EDIT: I misread, I though you wanted the distance of the line. The distance between a point and a line is basic algebra, google is your fried

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120