【问题标题】:Retinal blood vessel segmentation using Python使用 Python 进行视网膜血管分割
【发布时间】:2020-10-16 14:34:48
【问题描述】:

我有以下视网膜图像,我正在尝试追踪血管(从圆圈中出来的较暗的线)。这是原图:

我尝试使用除法归一化对图像进行阈值化,然后对轮廓区域进行过滤(根据不同的 stackoverflow 解决方案):

import cv2
import numpy as np

# read the image
img = cv2.imread('retina_eye.jpg')

# convert to gray
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# apply morphology
kernel = cv2.getStructuringElement(cv2.MORPH_RECT , (5,5))
morph = cv2.morphologyEx(gray, cv2.MORPH_DILATE, kernel)

# divide gray by morphology image
division = cv2.divide(gray, morph, scale=255)

# threshold
thresh = cv2.threshold(division, 0, 255, cv2.THRESH_OTSU )[1] 

# invert
thresh = 255 - thresh

# find contours and discard contours with small areas
mask = np.zeros_like(thresh)
contours = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours = contours[0] if len(contours) == 2 else contours[1]

area_thresh = 10000
for cntr in contours:
    area = cv2.contourArea(cntr)
    if area > area_thresh:
        cv2.drawContours(mask, [cntr], -1, 255, 2)

# apply mask to thresh
result1 = cv2.bitwise_and(thresh, mask)
mask = cv2.merge([mask,mask,mask])
result2 = cv2.bitwise_and(img, mask)

# save results
cv2.imwrite('retina_eye_division.jpg',division)
cv2.imwrite('retina_eye_thresh.jpg',thresh)
cv2.imwrite('retina_eye_mask.jpg',mask)
cv2.imwrite('retina_eye_result1.jpg',result1)
cv2.imwrite('retina_eye_result2.jpg',result2)

# show results
cv2.imshow('morph', morph)  
cv2.imshow('division', division)  
cv2.imshow('thresh', thresh)  
cv2.imshow('mask', mask)  
cv2.imshow('result1', result1)  
cv2.imshow('result2', result2)  
cv2.waitKey(0)
cv2.destroyAllWindows()

这是我得到的最终输出:

它最终追踪了船只,但也有一些背景噪音。

理想情况下,我正在寻找这个输出:

对于实现这个结果有什么建议吗?

【问题讨论】:

  • 我会先花时间获得更好的图像。这是一个什么样的成像系统?我没有看到解决这个混乱的算法解决方案。
  • 我在这里秒@Piglet,图像质量很差。除非我看到您的预期输出,否则我自己看不到所有容器。
  • @Piglet 好点,我已经用更高质量的图像更新了帖子。船只现在更加明显。很想听听你的建议!
  • 这是一个研究得很好的问题,有数百篇关于它的论文。我建议您从文献搜索开始:scholar.google.com/scholar?q=retinal+vessel+segmentation
  • 我想你想看看这个:stackoverflow.com/questions/62164546/…

标签: python opencv image-processing deep-learning image-segmentation


【解决方案1】:

我一直在研究使用深度学习进行视网膜血管分割的主题,您提出的问题基本相同。 我想与您分享我的研究。

在我们要分割的图像部分的强度或对比度非常低的情况下,我们必须应用CLAHE(对比度受限自适应直方图均衡)。获得非常好的结果是非常强大的技术。我想让你试试。让我也为您提供一些代码:

import cv2

bgr = cv2.imread(retinal_image)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
equalized = clahe.apply(gray)

此外,您还可以使用 Non Local Mean 对图像进行去噪。

如果您想了解整个过程是如何完成的,我建议您通过this easy paper了解整个过程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    • 2020-01-04
    • 1970-01-01
    相关资源
    最近更新 更多