hi
can anyone help me to develop GUI(graphic user interface) for my matlab code for retinal image analysis.my code is used to detect optic disc and exudate in retinal images using contour techniques
Moderators note: used code tags
can anyone help me to develop GUI(graphic user interface) for my matlab code for retinal image analysis.my code is used to detect optic disc and exudate in retinal images using contour techniques
Code:
clc
clear all
close all
%% Read images.
for count = 32:32
name = ['Images 1\' int2str(count) '.tif'];
img = imread(name);
res_img = imresize(img,[256 256]);
gr_img = rgb2gray(res_img);
figure(1),imshow(gr_img),title('Input Image')
pause(0.2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h = fspecial('unsharp');
filt_img = imfilter(res_img:),:,2),h);
h = fspecial('disk',4);
filt_img = imfilter(filt_img,h);
figure(2),imshow(filt_img),title('Filtered Image')
pause(0.2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bw = im2bw(filt_img,0.43);
% figure(3),imshow(bw),title('BW Image')
% pause(0.2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
se = strel('disk',5);
BW_erod = imopen(bw,se);
se = strel('disk',5);
BW_dil = imdilate(BW_erod,se);
% figure(4),imshow(BW_dil),title('Optic Disc')
% pause(0.2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[L num] = bwlabel(BW_dil);
if num == 0
% disp('1:Optic Disc - Not Spotted')
newstats = [];
elseif num > 1
newstats = [];
stats = regionprops(L,'basic');
for count2 = 1:length(stats)
if ((stats(count2).Centroid(1) >= 75 && stats(count2).Centroid(1) <= 110) || ...
(stats(count2).Centroid(1) >= 160 && stats(count2).Centroid(1) <= 190)) && ...
(stats(count2).Centroid(2) >= 110 && stats(count2).Centroid(2) <= 145)
newstats = stats(count2);
end
end
else
stats = regionprops(L,'basic');
if stats.Centroid(2) < 100 || stats.Centroid(2) > 150
% disp('3:Optic Disc - Not Spotted')
newstats = [];
else
newstats = stats;
end
end
if ~isempty(newstats)
if newstats.BoundingBox(3) < 50
newstats.BoundingBox(1) = newstats.BoundingBox(1) - ...
(50 - newstats.BoundingBox(3))/2;
newstats.BoundingBox(3) = 50;
end
if newstats.BoundingBox(4) < 50
newstats.BoundingBox(2) = newstats.BoundingBox(2) - ...
(50 - newstats.BoundingBox(4))/2;
newstats.BoundingBox(4) = 50;
end
if newstats.BoundingBox(3) > 100
newstats.BoundingBox(3) = 100;
end
if newstats.BoundingBox(4) > 140
newstats.BoundingBox(2) = newstats.BoundingBox(2) + 20;
newstats.BoundingBox(4) = 110;
end
region = imcrop(gr_img,newstats.BoundingBox);
uiloc = find(any(region<3));
if isempty(uiloc)
ROI = region;
elseif uiloc(1) == 1
ROI = region:),uiloc(length(uiloc))+1:end);
else
ROI = region:),1:uiloc(1)-1);
end
% figure(5),imshow(ROI),title('Input to Contour detection')
% pause(0.5)
imwrite(ROI,'ODisc.tif')
[ubin c xarr yarr cmat wdt] = test_activecontour('ODisc.tif',0,6);
pause(1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Applying Correlation to find segmented region..
disp('Computing Correlation...')
val = zeros(size(gr_img,1)-size(ROI,1),size(gr_img,2)-size(ROI,2));
for i = 1:size(gr_img,1)-size(ROI,1)
for j = 1:size(gr_img,2)-size(ROI,2)
portion = gr_img(i:i+size(ROI,1)-1,j:j+size(ROI,2)-1);
val(i,j) = corr2(ROI,portion);
end
end
[r,c] = find(val == 1);
rect = [c r size(ROI,2) size(ROI,1)];
figure(7),imshow(gr_img),title('Region Segmented')
rectangle('Position',rect,'EdgeColor','g')
pause(1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if newstats.Centroid(1) < 128
rem_reg = gr_img:),round(newstats.BoundingBox(1)+60):end);
else
rem_reg = gr_img:),1:round(newstats.BoundingBox(1)));
end
% figure(8),imshow(rem_reg),title('Remaining Region')
% pause(0.5)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pos = find(all(rem_reg'<3));
% diff_pos = diff(pos);
% sep_point = find(diff_pos > 1);
% rem_reg(pos(sep_point+1)-1:pos(end),:) = [];
% rem_reg(pos(1):sep_point+1,:) = [];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rem_reg(217:end,:) = [];
rem_reg(1:40,:) = [];
rem_loc = find(any(rem_reg<3));
if isempty(rem_loc)
rem_ROI = rem_reg;
elseif rem_loc(1) == 1
rem_ROI = rem_reg:),rem_loc(length(rem_loc))+1:end);
else
rem_ROI = rem_reg:),1:rem_loc(1)-1);
end
% figure(9),imshow(rem_ROI),title('Remaining region to Contour Detection')
% pause(0.5)
imwrite(rem_ROI,'RemR.tif')
[ubin c xarr yarr cmat wdt] = test_activecontour('RemR.tif',0,10);
pause(2)
else
disp('Optic Disc - Not Spotted')
end
% close all
end
Attachments
-
60.2 KB Views: 102
Last edited by a moderator: