How can I detect blood vessels in retinal image?

Answers (3)

Hi, is it possible to give the code source of MatchFilterAndGaussDerKernel and acc functions.
20.5 Retinal Images, Analysis of Eye, etc.
20.5.1 Retinal Images, Angiography, Blood Vessels in the Eye
20.5.2 Glaucoma Retinopathy, Retinal Analysis Application
20.5.3 Diabetic Retinopathy, Retinal Analysis Application
We can't help you with coding up some algorithm that we don't even know what it is yet. Pick an algorithm first, then give a shot at coding it up. http://matlab.wikia.com/wiki/FAQ#Can_you_program_up_the_algorithm_in_this_article_for_me_and_explain_it_to_me.3F
Then come back here if you have syntax problems, error messages, or need help with program flow.

11 Comments

Thank You. Will try to figure this out and inform u soon.
I have got a code and the approach used for blood vessels extraction is called the Matched FIlter - First Derivative of Gaussian. There are four M files. I am facing troubles while going through the code. Here is the code
function [Z] = main()
% Main function that calls all others
% Outputs:
% Z(1,1) - true positive rate
% Z(1,2) - true negative rate
% Z(1,3) - accuracy
Z = zeros(20,3);
MaskForGDRange = zeros(605,700);
for row = 1:605
for col = 1:700
if (row-302)*(row-302) + (col-350)*(col-350) > 62500
maskForGDRange(row,col) = 1;
end
end
end
idx = 1;
for k=[1:5 44 77 81:82 139 162:163 235:236 239 240 255 291 319 324]
k
mask_name = strcat('D:\MyD 1\stare- images\mask\im',num2str(k,'%04d'),'_mask.ppm');
mask = imread(mask_name);
mask = mask(:,:,2);
mask = logical(mask);
im_name = strcat('D:\MyD 1\stare-images\im',num2str(k,'%04d'),'.ppm');
im = imread(im_name);
se = strel('disk',2);
mask=imerode(mask,se);
im = double(im(:,:,2));
man_name = strcat('D:\MyD 1\stare-images\labels-ah\im',num2str(k,'%04d'),'.ah.ppm');
man = imread(man_name);
[vess1]=MatchFilterWithGaussDerivative([],1,im,1.5,1.5,9,5,41,201,8,mask,maskForGDRange,3,40);
[vess2]=MatchFilterWithGaussDerivative([],2,im,1,1,9,5,21,101,8,mask,maskForGDRange,2,40);
vess = vess1 | vess2;
[tpr tnr accu] = acc(vess, mask, man);
Z(idx,1,1) = tpr;
Z(idx,2,1) = 1 - tnr;
Z(idx,3,1) = accu;
idx = idx + 1;
end
return
This is the function M file used
function [vess] = MatchFilterWithGaussDerivative(k,num,im,sigmaForMF,sigmaForGD,yLengthForMF,yLengthForGD,tForMatchfilterRes,tForGaussDerRes, numOfDirections,mask,maskForGDRange,c_value,t)
% Retinal vessel extraction by matched filter with
% first-order derivative of Gaussian
% Inputs:
% k - ignore, used for testing purposes only
% num - image number
% im - input image
% sigmaForMF - scale value of MF
% sigmaForGD - scale value of FDOG
% yLengthForMF - length of neighborhood along y-axis of MF
% yLengthForGD - length of neighborhood along y-axis of FDOG
% tForMatchfilterRes - threshold value of MF
% tForGaussDerRes - threshold value of FDOG
% numOfDirections - number of orientations
% mask - image mask
% maskForGDRange - another image mask
% c_value - c value
% t - threshold value of MF-FDOG
%
% Output:
% vess - vessels extracted
if isa(im,'double')~=1
im = double(im);
end
[rows,cols] = size(im);
MatchFilterRes(rows,cols,numOfDirections) = 0;
GaussDerivativeRes(rows,cols,numOfDirections) = 0;
K2=tForMatchfilterRes;
S2=ones(K2,K2)/(K2^2);
for i = 0:numOfDirections-1
matchFilterKernel =
MatchFilterAndGaussDerKernel(sigmaForMF,yLengthForMF, pi/numOfDirections*i,0);
gaussDerivativeFilterKernel =
MatchFilterAndGaussDerKernel(sigmaForGD,yLengthForGD,
pi/numOfDirections*i,1);
MatchFilterRes(:,:,i+1) = conv2(im,matchFilterKernel,'same');
RDF = conv2(im,gaussDerivativeFilterKernel,'same');
GaussDerivativeRes(:,:,i+1) = abs(conv2(RDF,S2,'same'));
end
[maxMatchFilterRes] = max(MatchFilterRes,[],3);
accoGaussDerivativeRes = min(GaussDerivativeRes,[],3);
averageGD = conv2(accoGaussDerivativeRes,S2,'same');
meanGD = mean(mean(averageGD));
normalGD = averageGD / meanGD;
big = normalGD >= 5;
small = normalGD < 5;
W = c_value + normalGD / 2;
W = W .* ~maskForGDRange;
W = W + maskForGDRange * c_value;
K1 = tForGaussDerRes;
S1=ones(K1,K1)/(K1^2);
averageMF = conv2(maxMatchFilterRes,S1,'same');
vess = (maxMatchFilterRes - W.*averageMF)>0;
vess = vess & mask;
se = strel('square',3);
vess = imclose(vess,se);
vess = bwmorph(vess,'close');
[L num] = bwlabel(vess, 8);
prop = regionprops(L, 'Area');
idx = find([prop.Area] > t);
vess = ismember(L,idx);
if you can explain me briefly wat this code is actually performing then it would be very helpful to me.Thanx by the way.
D:\MyD 1\stare- images\mask\im',num2str(k,'%04d'),'_mask.ppm Which is this image ....Please reply me quickly.
Can you provide all 4 .m files and source code of MatchFilterAndGaussDerKernel and acc functions plz ?
Hi i would like to extract the blood vessels from fundus images but still i try to many coding for the extraction process but the blood vessles are not segemented properly so please help me how can extract the blood vessels in fundus image
plz contact my Mail Id sowmiyajagadeesan1999@gmail.com
OK, exactly what does "help" look like for you?
Do you need to know how and what to specifically ask for? If so, see this link.
Do you need someone to program up one of the papers in the link I gave? If so, see this link, for 4 good options.
hello sir , i have simple doubt...whether i can use the same concept for "yarn based feature extraction"?? I wish to apply same blood vessel extraction algorithm ... is it work?
My MATLAB R2020a trial version expired. Can you renew that trial version for 3/6 months??
I don't know what "yarn based feature extraction" is, or if it will work on blood vessels. Give it a try.
If you want to use MATLAB for another 3 to 6 months beyond the original one month, then you'll have to buy a version. You can't just keep using it forever and getting free extensions. You realize that the people who write MATLAB for you deserve to get a paycheck just like you, right?

Sign in to comment.

Hi Biswarup... this is a code for retinal vessel segmentation with Matched filter and first derivative of gaussian filter.
I have attached the supporting paper for the code... refer that for explanation

2 Comments

Where is the code for this paper ?
It would be with the authors. Generally code is not submitted as a separate file along with the article, unless it's actually part of the article itself.

Sign in to comment.

Asked:

on 6 Nov 2013

Commented:

on 31 Aug 2020

Community Treasure Hunt

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

Start Hunting!