How to improve vessel segmentation such that parts of blood vessels are not being removed when removing small contours?

735 views Asked by At

Am able to somewhat segment the blood vessels through subtracting blurred image from the green channel image, but several vessels contours are still removed when removing contours under a certain area (noise). I am currently removing any contours under 100 area, but when I move up to 1000, or 500, many of the vessels get broken up.

First, I subtracted a median blurred green channel from the original green channel image. I tried simple cv2.blur, median blur, and bilateral filter, but the results are virtually the same. I don't know if I need to do certain morphological operations, but the overall goal is too make sure that the blood vessel contours are still connected when I remove larger noise contours.

Code:

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

This is the original: Original Image

This is what I can create without removing too much noise: Lots of Noise

Little noise: Little Noise

But when I do have little noise, some eyes have blood vessels split and get removed halfway: Problem when Little Noise

0

There are 0 answers