www.pudn.com > Ashkan.zip > Ashkan.m, change:2015-04-15,size:2443b


clear all; 
close all; 
im = imread('img (60).tif' ); 
im = im2double(im); 
%----------rgbtohsi 
r=im(:,:,1); 
g=im(:,:,2); 
b=im(:,:,3); 
th=acos((0.5*((r-g)+(r-b)))./((sqrt((r-g).^2+(r-b).*(g-b)))+eps)); 
H=th; 
H(b>g)=2*pi-H(b>g); 
H=H/(2*pi); 
S=1-3.*(min(min(r,g),b))./(r+g+b+eps); 
I=(r+g+b)/3; 
hsi=cat(3,H,S,I); 
%figure,subimage(im),title('RGB Image'); 
%figure,subimage(I),title('Intensity Image'); 
subplot(1,3,1), imshow(im), title('RGB' ); 
subplot(1,3,2), imshow(I), title('intensity' ); 
%----------apply median filter on I band 
medI = medfilt2(I); 
%----------apply contrast inhancement on I band 
I2 = adapthisteq(medI, 'clipLimit' ,0.015, 'Distribution' , 'rayleigh' ); 
%----------removing vessels 
se = strel('disk' ,8); 
Ia = imclose(I2,se); % Ia correspond to 3a in paper 
%----------binarized Ia 
Ib = im2bw(Ia, 0.63); % Ib correspond to 3b in paper 
%----------elimiate Threshold from I2 
Ic = I2 - Ib; % Ic correspond to 3c in paper 
%----------mask is I2 and marker Ic is 
Id = imreconstruct(Ic, I2); % Id correspond to 3d in paper 
%----------steps to achieve to 3e 
Isub = I2 - Id; 
level = graythresh(Isub); 
Ie = im2bw(Isub,level); 
%----------finding bigest circle and remove it from I 
se = strel('disk' ,10); 
Ie = imopen(Ie,se); 
se = strel('disk' ,10); 
Ie = imclose(Ie,se); 
CC = bwconncomp(Ie); 
numPixels = cellfun(@numel,CC.PixelIdxList); 
se = strel('disk' ,1); 
borders = Ie - imerode(Ie,se); 
DD = bwconncomp(borders); 
borPixels = cellfun(@numel,DD.PixelIdxList); 
M = 4*pi*(numPixels ./ (borPixels).^2); 
[biggest,indx] = max(M); 
temp = Ie; 
temp(CC.PixelIdxList{indx}) = 0; 
Ie2 = Ie - temp; 
se = strel('disk' ,20); 
Ie2 = imdilate(Ie2,se); 
If = I - Ie2; 
figure, imshow(If),title('removing optic disk'); 
%----------local variation 
se = strel('disk' ,5); 
I4 = imclose(If,se); 
a4 = stdfilt(I4, ones(3,3)); % a4 correspond to 4a in paper 
%----------binarized a4 
level = graythresh(a4); 
b4 = im2bw(a4,level/7); % b4 correspond to 4b in paper 
se = strel('disk' ,5); 
b4 = imdilate(b4,se); 
%----------removing rings to achieve to 4d 
se = strel('line' ,40,90); 
bb4 = imerode(b4,se); 
b4rc = imreconstruct(bb4,b4); 
d4 = b4 - b4rc; 
 
e4 = I2 - d4; 
 
f4 = imreconstruct(e4,I2); 
%----------e4 and binarized it 
g4 = I2 - f4; 
g4 = im2bw(g4,0.01); 
%----------compose result and intensity image 
h = imfuse(g4,I); 
h = rgb2gray(h); 
%subplot(1,3,3), imshow(h), title('result' ); 
imshow(h);