简体   繁体   English

等高线中点之间的距离

[英]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. 为此,我对图像进行了阈值处理,并提取了最大的3个轮廓,其中一个是角膜,另一个是晶状体的内部和外部边缘。 影像轮廓

I need to check for the distance between the green contour and the red one all along the x axis in the image. 我需要检查沿图像中x轴的绿色轮廓和红色轮廓之间的距离。

I tried to check for contour distance in OpenCV but did not find anything. 我试图在OpenCV中检查轮廓距离,但没有找到任何东西。

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. 我已经手动编辑了图像,以便仅考虑图像的相关部分。

删除了不相关部分的图像。

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可以从数据中找到函数。 Scipy.interp1d() found the function (in cyan) from the red line's contours: Scipy.interp1d()从红线的轮廓中找到了函数(青色):

曲线

Next, I could find the distance from the green line (the contours of the cornea), to the nearest point on the curve: 接下来,我可以找到从绿线(角膜的轮廓)到曲线上最近的点的距离:

最近的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM