Need help in removing salt and pepper noise for blood vessel extraction while keeping vessel information using OpenCV in Python

Viewed 367

I am currently trying to extract blood vessels from an image of the eye. So far, I have been able to display the blood vessels, but there is still a significant amount of noise around the image - it seems like salt and pepper noise. I want to try and highlight the blood vessels even more so only they appear. I am currently using OpenCV in Python.

I have tried to use different types of blur such as Median Blur. I also tried Open, Close, Dilation, and Erosion, but the noise still remains. I am not sure what the next step could be.

Here is my code:

r = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
threshold=cv2.adaptiveThreshold(r, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 91, 2.)
ret,f6 = cv2.threshold(threshold,0,250,cv2.THRESH_BINARY)

morph_img = cv2.morphologyEx(f6, cv2.MORPH_CLOSE, kernel)
imagem = cv2.bitwise_not(morph_img)
imagem2 = cv2.bilateralFilter(imagem,9,55,55)
imagem3 = cv2.medianBlur(imagem2,5)
imagem3 = cv2.bilateralFilter(imagem3,7,55,55)
imagem3 = cv2.dilate(imagem3,kernel,iterations=5)
imagem3 = cv2.medianBlur(imagem3,5)

return imagem3

I would just like to see the blood vessels on the black screen. It needs to be so that the blood vessels are also continuous as well.

This is the current image I am able to produce:

Current image

Original Image

Original

1 Answers

Let me guess glaucoma detection? I think for a specific task you have to find specific paper for proper method

adaptiveThreshold may not be a good choice. consider the change to other methods like co segmentation with a clean Black white blood vessel as co-map. Or an active contour model or variational energy model. The others are more often used in this sort of segmentation work.

If you just want some post processing filter. As you said, for salt and paper noise, typically should be nonlinear filter like a median filter

More recently there is this guided filter which should help in your case as well. You can define your guide I. But I doubt it is post-processing filter issue. High chance your raw segmentation result is really really bad

enter image description here

Go google search ASTAR glaucoma detection segmentation, you will have a series of paper that you can follow. ASTAR was the leading party in this series of research work at least in 2014 or at least that was they told me. I attend their lecture like in 2012-2014. Didn`t work on it so much later. At that time they are using Active contour models like Snake energy function. Now they are switching to pure deep learning based method. You can contact them to get a trial source code.

Deep learning is one of the easier way to do so just provide the input and the thing you wanted. It can get for you. For start, you can start with Vgg16 and slowly improving.

Good luck and have fun with image segmentation.

Related