[英]How can I find specific points in binary images?
I'm starting a research at the university, with the theme of enabling the use of AI to calculate a region of the retina.我正在大学开始一项研究,其主题是能够使用 AI 来计算视网膜区域。 The first part we stipulated was to segment two important parts of the retina, using u-net.
我们规定的第一部分是使用 u-net 分割视网膜的两个重要部分。 The second is to use the result of segmentation to find the important points and perform a calculation.
二是利用分割的结果找出重要的点并进行计算。
So, in the below image, I show the output of segmentation each region, using u-net (The red annotation isn't part of segmentation).因此,在下图中,我使用 u-net 显示了每个区域的分割输出(红色注释不是分割的一部分)。 I tried represent regions that I want find in first and second block.
我尝试表示我想在第一个和第二个块中找到的区域。 Once did, I could calculate distance between these points, when merge them.
一旦这样做了,我就可以在合并它们时计算这些点之间的距离。 So, my question is: what kind of technique I can use to read the pixels in order of to find the coordinates where I marked?
所以,我的问题是:我可以使用什么样的技术来读取像素以便找到我标记的坐标?
Is OpenCV a lib that could help me? OpenCV 是一个可以帮助我的库吗? It's the first time that I handle with this kind of problem, so thanks for any suggestion or guidance.
这是我第一次处理这种问题,所以感谢您的任何建议或指导。
Using OpenCV: detecting the margins can be done with connectedComponentsWithStats() method.使用 OpenCV:可以使用 connectedComponentsWithStats() 方法检测边距。
connectivity = 8
output = cv2.connectedComponentsWithStats(binary_img, connectivity, cv2.CV_32S)
stats = output[2] # stat matrix
first_blob_left = stats[0,cv2.CC_STAT_LEFT]
first_blob_right = stats[0,cv2.CC_STAT_RIGHT]
second_blob_left = stats[1,cv2.CC_STAT_LEFT]
second_blob_right = stats[1,cv2.CC_STAT_RIGHT]
if first_blob_left < second_blob_left:
dist = second_blob_left - first_blob_right
else:
dist = first_blob_left - second_blob_right
detecting the deepest point can be done with the same method:可以使用相同的方法检测最深点:
connectivity = 8
output = cv2.connectedComponentsWithStats(binary_img, connectivity, cv2.CV_32S)
stats = output[2] # stat matrix
blob_top = stats[0,cv2.CC_STAT_TOP]
blob_height = stats[0,cv2.CC_STAT_HEIGHT]
deepest_point_y_position = blob_top + blob_height
Note: This code hasn't been tested, it may contains some typos.注意:此代码尚未经过测试,可能包含一些拼写错误。 But still, the idea stays the same, and should work without much effort.
但是,这个想法保持不变,应该毫不费力地工作。
Take a look at看一眼
labels = output[1]
"labels" is an array the site of the input image, where each pixel of a blob is labelled with the same value. “labels”是输入图像所在位置的数组,其中 blob 的每个像素都标有相同的值。 This should help you to find the coordinates of the margins
这应该可以帮助您找到边距的坐标
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.