如何改善血管分割,以便在去除小轮廓时不会去除血管的一部分?

时间:2019-06-20 18:22:30

标签: python image opencv image-segmentation retina

能够通过从绿色通道图像中减去模糊图像来对血管进行某种程度的分割,但是当在特定区域(噪声)下移除轮廓时,仍会移除多个血管轮廓。我目前正在删除100区域以下的所有轮廓,但是当我移动到1000或500时,很多血管都破裂了。

首先,我从原始绿色通道图像中减去中值模糊的绿色通道。我尝试了简单的cv2.blur,中值模糊和双边过滤器,但结果实际上是相同的。我不知道是否需要进行某些形态学操作,但是总体目标还是要确保在删除较大的噪声轮廓时仍保持血管轮廓连接。

代码:

import os 
import numpy as np
import cv2
def vessels(file):
    img = cv2.imread(file)

    #green channel extraction to provide most vessel information
    imgG = img[:,:,1]

    imgblurred = cv2.blur(imgG, (100,100)) 

    f5 = imgG - imgblurred


    ret,f6 = cv2.threshold(f5,15,255,cv2.THRESH_BINARY)    
    mask = np.ones(f5.shape[:2], dtype="uint8") * 255    
    im2, contours, hierarchy = cv2.findContours(f6.copy(),cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)
    for cnt in contours:
        if cv2.contourArea(cnt) <= 100:
            cv2.drawContours(mask, [cnt], -1, 0, -1)            
    im = cv2.bitwise_and(f5, f5, mask=mask)
    ret,fin = cv2.threshold(im,15,255,cv2.THRESH_BINARY_INV)

    return fin

这是原始文件: Original Image

这是我可以在不消除过多噪音的情况下创建的: Lots of Noise

噪音小: Little Noise

但是当我的声音很小的时候,有些眼睛的血管就会裂开并在中途摘除: Problem when Little Noise

0 个答案:

没有答案