Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove optical disk image of the retina, setting the color of the optical disk as background color

I've been working with the retina image, currently I am submitting to the wavelet, but I have noticed that I have two problems are:

  • The optical disk which causes me image noise
  • And the circle delimiting the retina

The original image is the next

original image

My plan is to establish the bottom of the tone of the optical disk in order not to lose any detail of the blood vessels of the retina (I post a code with which I played but still do not understand much as I know the tone of the optical disc and how to set it to the image without altering the blood vessels)

And with respect to the outer circle of the retina, I don´t know that you recommend me (I do not know about masks, I would appreciate if they have to consult my literature can provide)

 c = [242 134 72];% Background to change
 thresh = 50;
 A = imread('E:\Prueba.jpg');

 B = zeros(size(A));
 Ar = A(:,:,1);
 Ag = A(:,:,2);
 Ab = A(:,:,3);

 Br = B(:,:,1);
 Bg = B(:,:,2);
 Bb = B(:,:,3);


 logmap = (Ar > (c(1) - thresh)).*(Ar < (c(1) + thresh)).*...
 (Ag > (c(2) - thresh)).*(Ag < (c(2) + thresh)).*...
 (Ab > (c(3) - thresh)).*(Ab < (c(3) + thresh));
 Ar(logmap == 1) = Br(logmap == 1);
 Ag(logmap == 1) = Bg(logmap == 1); 
 Ab(logmap == 1) = Bb(logmap == 1);
 A = cat(3 ,Ar,Ag,Ab);
 imshow(A);

courtesy of the question How can I change the background color of the image?

The image I get is the following

enter image description here

I need a picture like this where the optical disc does not cause me noise when segmenting the blood vessels of the retina.

enter image description here

I want to be uniform background ... and only the veins are perceived

I continued to work and have obtained the following image As you can realize the optical disk removes some parts of the blood vessels (veins) that are above him, so I require eliminating or make uniform the entire bottom of the image.

Enhancement image

like image 789
Colours123 Avatar asked Sep 23 '16 17:09

Colours123


2 Answers

As Wouter said, you should first correct the inhomogeneity of the image. I would do it in my own way:

First, the parameters you can adjust to optimize the output:

gfilt = 3;
thresh = 0.4;
erode = 3;
brighten = 20;

You will see how they are used in the code.

This is the main step: to apply a Gaussian filter to the image to make it smooth and then subtract the result from the original image. This way you end up with the sharp changes in your data, which happens to be the vessels:

A = imread('Prueba.jpg');
B = imgaussfilt(A, gfilt) - A; % Gaussian filter and subtraction
% figure; imshow(B)

enter image description here

Then I create a binary mask to remove the unwanted area of the image:

% the 'imadjust' makes sure that you get the same result even if you ...
% change the intensity of illumination. "thresh" is the threshold of ...
% conversion to black and white:
circ = im2bw(imadjust(A(:,:,1)), thresh);
% here I am shrinking the "circ" for "erode" pixels:
circ = imerode(circ, strel('disk', erode));
circ3 = repmat(circ, 1, 1, 3); % and here I extended it to 3D.
% figure; imshow(circ)

enter image description here

And finally, I remove everything on the surrounding dark area and show the result:

B(~circ3) = 0; % ignore the surrounding area
figure; imshow(B * brighten) % brighten and show the output

enter image description here

Notes:

  • I do not see the last image as a final result, but probably you could apply some thresholds to it and separate the vessels from the rest.
  • The quality of the image you provided is quite low. I expect good results with a better data.
  • Although the intensity of blue channel is less than the rest, the vessels are expressed there better than the other channels, because blood is red!
  • If you are acquiring this data or you have access to the person, I suggest you to use blue light for illumination, since it provides you with higher contrast of the vessels.
like image 73
erfan Avatar answered Oct 22 '22 11:10

erfan


Morphological operations are good for working with sphagetti images.

Original image:

Original image

Convert to grayscale:

original = rgb2gray(gavrF);

Estimate the background via morphological closing:

se = strel('disk', 3);
background = imclose(original, se);

Estimate of the background:

estimate of the background

You could then for example subtract this background from the original grayscale image. You can do this straight by doing a bottom hat transform on the grayscale image:

flatImage = imbothat(original, strel('disk', 4));

With a output:

enter image description here

Noisy, but now you got access to global thresholding methods. Remember to change the datatypes to double if you wish to do some subtraction or division manually.

like image 24
Tapio Avatar answered Oct 22 '22 11:10

Tapio