How can I get this code to show only the veins in a fundus image of an eye ?

6 Ansichten (letzte 30 Tage)
I have been trying to run a code in order to extract the retinal veins fromt he fundus image of an eye however it keeps giving me such erroneous output. I am including the part for extracting veins , however I am unsure so as to what is going wrong with this.
Code:
Coloured = imread('fundus_image');
Converted_Image = im2double(Coloured);
Lab_Image = rgb2lab(Converted_Image);
fill = cat(3, 1,0,0);
Filled_Image = bsxfun(@times, fill, Lab_Image);
Reshaped_Lab_Image = reshape(Filled_Image, [], 3);
[C, S] = pca(Reshaped_Lab_Image);
S = reshape(S, size(Lab_Image));
S = S(:, :, 1);
Gray_Image = (S-min(S(:)))./(max(S(:))-min(S(:)));
Enhanced_Image = adapthisteq(Gray_Image, 'numTiles', [8 8], 'nBins', 256);
Avg_Filter = fspecial('average', [9 9]);
Filtered_Image = imfilter(Enhanced_Image, Avg_Filter);
Substracted_Image = imsubtract(Filtered_Image,Enhanced_Image);
Image = im2uint8(Substracted_Image(:));
[Histogram_Count,Bin_Number]=imhist(Image);
i = 1;
Cumulative_Sum = cumsum(Histogram_Count);
T(i) = (sum(Bin_Number.*Histogram_Count))/Cumulative_Sum(end);
T(i)=round(T(i));
Cumulative_Sum_2 = cumsum(Histogram_Count(1:T(i)));
MBT=sum(Bin_Number(1:T(i)).*Histogram_Count(1:T(i)))/Cumulative_Sum_2(end);
Cumulative_Sum_3=cumsum(Histogram_Count(T(i):end));
MAT=sum(Bin_Number(T(i):end).*Histogram_Count(T(i):end))/Cumulative_Sum_3(end);
i = i+1;
T(i) = round((MAT+MBT)/2);
while abs(T(i)-T(i-1))>=1
Cumulative_Sum_2 = cumsum(Histogram_Count(1:T(i)));
MBT=sum(Bin_Number(1:T(i)).*Histogram_Count(1:T(i)))/Cumulative_Sum_2(end);
Cumulative_Sum_3=cumsum(Histogram_Count(T(i):end));
MAT=sum(Bin_Number(T(i):end).*Histogram_Count(T(i):end))/Cumulative_Sum_3(end);
i = i+1;
T(i) = round((MAT+MBT)/2);
Threshold = T(i);
end
level = (Threshold - 1) / (Bin_Number(end) - 1);
Binary_Image = imbinarize(Substracted_Image, level-0.008);
Clean_Image = bwareaopen(Binary_Image, 100);
figure, imshow(Clean_Image);
--> Any help is most appreciated.

Antworten (1)

Image Analyst
Image Analyst am 15 Mär. 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by