David Maseda Neira
David Maseda Neira

Reputation: 202

Distance between points in contours opencv

I'm trying to develop a solution to segment corneal tomographies, and check for the distance between the cornea and a contact lens. For such, i thresholded the image and extracted the biggest 3 contours, being one of the cornea and the other 2 the interior and exterior edges of the lens. Image contours

I need to check for the distance between the green contour and the red one all along the x axis in the image.

I tried to check for contour distance in OpenCV but did not find anything.

Upvotes: 2

Views: 2708

Answers (1)

Stephen Meschke
Stephen Meschke

Reputation: 2940

This answer explains how to find the radial distance between the red line and the green line. I have manually edited the image so that only the relevant parts of the image are considered.

Image with non-relevant parts removed.

The first step is to find a function that describes the curve of the lens (the red line). Scipy can find functions from data. Scipy.interp1d() found the function (in cyan) from the red line's contours:

Curve

Next, I could find the distance from the green line (the contours of the cornea), to the nearest point on the curve:

Nearest

Upvotes: 2

Related Questions