- 20.5 Retinal Images, Analysis of Eye, etc.
- 20.5.1 Eye, Cornea, Corneal Images
- 20.5.2 Optic Disc Location, Optic Disc Detection
- 20.5.3 Retinal Images, Angiography, Blood Vessels in the Eye
- 20.5.3.1 Retinal Microaneurysms, Detection
- 20.5.4 Glaucoma Retinopathy, Retinal Analysis Application
- 20.5.5 Cataracts, Detection, Analysis, Surgery
- 20.5.6 Diabetic Retinopathy, Retinal Analysis Application
- 20.5.7 Macular Degeneration Detection, AMD, Retinal Analysis Application
- 20.5.8 Retinal Images, Optical Coherence Tomography, OCT
how to get better preprocessing results
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Walaa
am 10 Dez. 2022
Beantwortet: Image Analyst
am 10 Dez. 2022
I'm using the steps in the code below as preprocessing steps before cup and disc segmentation of a retinal image. any advices for better results?
these are the results that I get:
InputImage=imread('18.png');
%preprocessing
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.97]);
% Give a name to the title bar.
set(gcf,'name','Preprocessing for optic Cup extraction','numbertitle','off')
subplot(2,3,1)
imshow(InputImage)
axis on;
title('Original Image')
%-------------------------------------------------------------------------------------------------------------------------------------------
%segementation and removal of blood vessels
IMAGE = im2double(InputImage);
% Convert RGB to Gray via PCA
lab = rgb2lab(IMAGE);
f = 0;
wlab = reshape(bsxfun(@times,cat(3,1-f,f/2,f/2),lab),[],3);
[C,S] = pca(wlab);
S = reshape(S,size(lab));
S = S(:,:,1);
gray = (S-min(S(:)))./(max(S(:))-min(S(:)));
%% Contrast Enhancment of gray image using CLAHE
J = adapthisteq(gray,'numTiles',[8 8],'nBins',128);
%% Background Exclusion
% Apply Average Filter
h = fspecial('average', [9 9]);
JF = imfilter(J, h);
% Take the difference between the gray image and Average Filter
Z = imsubtract(JF, J);
%% Threshold using the IsoData Method
level=isodata(Z); % this is our threshold level
%level = graythresh(Z)
%% Convert to Binary
BW = imbinarize(Z, level-.003);
%% Remove small pixels
BW2 = bwareaopen(BW, 350);
%% Overlay
BW2 = imcomplement(BW2);
out = imoverlay(InputImage, BW2, [0 0 0]);
subplot(2,3,2);
imshow(out);
axis on;
title('Segmented blood vessels');
mask=rgb2gray(out);
mask=logical(mask);
%Inpaint the original image by removing the text overlays.
J = inpaintCoherent(InputImage,mask);
subplot(2,3,3);
imshow(J);
axis on;
title('Removed blood vessels using inpaint coherent');
%Display the original image and the inpainted image.
y= inpaintExemplar(J,mask,'FillOrder','tensor','PatchSize',18);
subplot(2,3,4)
imshow(y);
axis on;
title('Further removal of blood vessels using inpaint exemplar')
%---------------------------------------------------------------------------------------------------------------------------------------------
%noise removal&smoothing of the retinal image
rgbImage = y;
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows, ~, numberOfColorBands] = size(rgbImage);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Median Filter the channels:
redMF = medfilt2(redChannel, [5, 5]);
greenMF = medfilt2(greenChannel, [5, 5]);
blueMF = medfilt2(blueChannel, [5, 5]);
% Find the noise in the red.
noiseImage = redChannel > 10;
% Get rid of the noise in the red by replacing with median.
noiseFreeRed = redChannel;
noiseFreeRed(noiseImage) = redMF(noiseImage);
% Find the noise in the green.
noiseImage = greenChannel > 20;
% Get rid of the noise in the green by replacing with median.
noiseFreeGreen = greenChannel;
noiseFreeGreen(noiseImage) = greenMF(noiseImage);
% Find the noise in the blue.
noiseImage = blueChannel > 100;
% Get rid of the noise in the blue by replacing with median.
noiseFreeBlue = blueChannel;
noiseFreeBlue(noiseImage) = blueMF(noiseImage);
% Reconstruct the noise free RGB image
rgbFixed = cat(3, noiseFreeRed, noiseFreeGreen, noiseFreeBlue);
subplot(2, 3,5);
imshow(rgbFixed);
axis on;
impixelinfo; % Allow user to mouse around and see the pixel values and coordinates.
title('Smoothed image');
%--------------------------------------------------------------------------------------------------------------------------------------------
%enhance contrast
shadow = rgbFixed;
shadow_lab = rgb2lab(shadow);
%The values of luminosity span a range from 0 to 100. Scale the values to the range [0 1], which is the expected range of images with data type double.
max_luminosity = 100;
L = shadow_lab(:,:,1)/max_luminosity;
%Perform the three types of contrast adjustment on the luminosity channel, and keep the a* and b* channels unchanged. Convert the images back to the RGB color space.
shadow_imadjust = shadow_lab;
shadow_imadjust(:,:,1) = imadjust(L)*max_luminosity;
shadow_imadjust = lab2rgb(shadow_imadjust);
subplot(2,3,6);
imshow(shadow_imadjust);
axis on;
title('Enhanced contrast');
uiwait(helpdlg('Examine the figures, then click OK to finish.'));
InputImage=imread(inp1);
%preprocessing
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.97]);
% Give a name to the title bar.
set(gcf,'name','Preprocessing for optic Cup extraction','numbertitle','off')
subplot(2,3,1)
imshow(InputImage)
axis on;
title('Original Image')
%-------------------------------------------------------------------------------------------------------------------------------------------
%segementation and removal of blood vessels
IMAGE = im2double(InputImage);
% Convert RGB to Gray via PCA
lab = rgb2lab(IMAGE);
f = 0;
wlab = reshape(bsxfun(@times,cat(3,1-f,f/2,f/2),lab),[],3);
[C,S] = pca(wlab);
S = reshape(S,size(lab));
S = S(:,:,1);
gray = (S-min(S(:)))./(max(S(:))-min(S(:)));
%% Contrast Enhancment of gray image using CLAHE
J = adapthisteq(gray,'numTiles',[8 8],'nBins',128);
%% Background Exclusion
% Apply Average Filter
h = fspecial('average', [9 9]);
JF = imfilter(J, h);
% Take the difference between the gray image and Average Filter
Z = imsubtract(JF, J);
%% Threshold using the IsoData Method
level=isodata(Z); % this is our threshold level
%level = graythresh(Z)
%% Convert to Binary
BW = imbinarize(Z, level-.003);
%% Remove small pixels
BW2 = bwareaopen(BW, 350);
%% Overlay
BW2 = imcomplement(BW2);
out = imoverlay(InputImage, BW2, [0 0 0]);
subplot(2,3,2);
imshow(out);
axis on;
title('Segmented blood vessels');
mask=rgb2gray(out);
mask=logical(mask);
%Inpaint the original image by removing the text overlays.
J = inpaintCoherent(InputImage,mask);
subplot(2,3,3);
imshow(J);
axis on;
title('Removed blood vessels using inpaint coherent');
%Display the original image and the inpainted image.
y= inpaintExemplar(J,mask,'FillOrder','tensor','PatchSize',18);
subplot(2,3,4)
imshow(y);
axis on;
title('Further removal of blood vessels using inpaint exemplar')
%---------------------------------------------------------------------------------------------------------------------------------------------
%noise removal&smoothing of the retinal image
rgbImage = y;
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows, ~, numberOfColorBands] = size(rgbImage);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Median Filter the channels:
redMF = medfilt2(redChannel, [5, 5]);
greenMF = medfilt2(greenChannel, [5, 5]);
blueMF = medfilt2(blueChannel, [5, 5]);
% Find the noise in the red.
noiseImage = redChannel > 10;
% Get rid of the noise in the red by replacing with median.
noiseFreeRed = redChannel;
noiseFreeRed(noiseImage) = redMF(noiseImage);
% Find the noise in the green.
noiseImage = greenChannel > 20;
% Get rid of the noise in the green by replacing with median.
noiseFreeGreen = greenChannel;
noiseFreeGreen(noiseImage) = greenMF(noiseImage);
% Find the noise in the blue.
noiseImage = blueChannel > 100;
% Get rid of the noise in the blue by replacing with median.
noiseFreeBlue = blueChannel;
noiseFreeBlue(noiseImage) = blueMF(noiseImage);
% Reconstruct the noise free RGB image
rgbFixed = cat(3, noiseFreeRed, noiseFreeGreen, noiseFreeBlue);
subplot(2, 3,5);
imshow(rgbFixed);
axis on;
impixelinfo; % Allow user to mouse around and see the pixel values and coordinates.
title('Smoothed image');
%--------------------------------------------------------------------------------------------------------------------------------------------
%enhance contrast
shadow = rgbFixed;
shadow_lab = rgb2lab(shadow);
%The values of luminosity span a range from 0 to 100. Scale the values to the range [0 1], which is the expected range of images with data type double.
max_luminosity = 100;
L = shadow_lab(:,:,1)/max_luminosity;
%Perform the three types of contrast adjustment on the luminosity channel, and keep the a* and b* channels unchanged. Convert the images back to the RGB color space.
shadow_imadjust = shadow_lab;
shadow_imadjust(:,:,1) = imadjust(L)*max_luminosity;
shadow_imadjust = lab2rgb(shadow_imadjust);
subplot(2,3,6);
imshow(shadow_imadjust);
axis on;
title('Enhanced contrast');
uiwait(helpdlg('Examine the figures, then click OK to finish.'));
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 10 Dez. 2022
Lots of papers on the subject in VisionBibliography. I have not read them but you can. See if any might help you.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Biomedical Imaging finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!