Error while evaluationg UIcontrolm Callback.
이전 댓글 표시
function varargout = Glaucoma_Detection(varargin)
% GLAUCOMA_DETECTION MATLAB code for Glaucoma_Detection.fig
% GLAUCOMA_DETECTION, by itself, creates a new GLAUCOMA_DETECTION or raises the existing
% singleton*.
%
% H = GLAUCOMA_DETECTION returns the handle to a new GLAUCOMA_DETECTION or the handle to
% the existing singleton*.
%
% GLAUCOMA_DETECTION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GLAUCOMA_DETECTION.M with the given input arguments.
%
% GLAUCOMA_DETECTION('Property','Value',...) creates a new GLAUCOMA_DETECTION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Glaucoma_Detection_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Glaucoma_Detection_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Glaucoma_Detection
% Last Modified by GUIDE v2.5 19-Apr-2018 10:21:01
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Glaucoma_Detection_OpeningFcn, ...
'gui_OutputFcn', @Glaucoma_Detection_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Glaucoma_Detection is made visible.
function Glaucoma_Detection_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Glaucoma_Detection (see VARARGIN)
% Choose default command line output for Glaucoma_Detection
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Glaucoma_Detection wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% Choose default command line output for testfinal
handles.output = hObject;
a=ones(256,256);
b=imread('images.jpeg');
axes(handles.axes3);
imshow(b);
axes(handles.axes2);
imshow(a);
axes(handles.axes1);
imshow(a);
%Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = Glaucoma_Detection_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function ANGLE_Callback(hObject, eventdata, handles)
% hObject handle to ANGLE (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of ANGLE as text
% str2double(get(hObject,'String')) returns contents of ANGLE as a double
% --- Executes during object creation, after setting all properties.
function ANGLE_CreateFcn(hObject, eventdata, handles)
% hObject handle to ANGLE (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function STATUS1_Callback(hObject, eventdata, handles)
% hObject handle to STATUS1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of STATUS1 as text
% str2double(get(hObject,'String')) returns contents of STATUS1 as a double
% --- Executes during object creation, after setting all properties.
function STATUS1_CreateFcn(hObject, eventdata, handles)
% hObject handle to STATUS1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in delete.
function delete_Callback(hObject, eventdata, handles)
% hObject handle to delete (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file, pathname] = uigetfile('*.bmp', 'Pick an Image');
if isequal(file,0) | isequal(pathname,0)
warndlg('User pressed cancel')
else
a=file;
delete(a);
uiwait(msgbox('File Deleted Succesfully','Message','modal'));
end
% --- Executes on button press in clear.
function clear_Callback(hObject, eventdata, handles)
% hObject handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=ones(256,256);
axes(handles.axes1);
imshow(a);
axes(handles.axes2);
imshow(a);
bb='0'
set(handles.ANGLE,'String',bb);
bb='0'
set(handles.STATUS1,'String',bb);
% --- Executes on button press in help.
function help_Callback(hObject, eventdata, handles)
% hObject handle to help (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
helpwin ch1;
% --- Executes on button press in exist.
function exist_Callback(hObject, eventdata, handles)
% hObject handle to exist (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
exit;
% --- Executes on button press in load.
function load_Callback(hObject, eventdata, handles)
% hObject handle to load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file, pathname] = uigetfile('*.jpeg', 'Pick an Image');
if isequal(file,0) | isequal(pathname,0)
warndlg('User pressed cancel')
else
a=imread(file);
axes(handles.axes1);
imshow(a);
handles.file=file;
%Update handles structure
guidata(hObject, handles);
end
% --- Executes on button press in enhacement.
function enhacement_Callback(hObject, eventdata, handles)
% hObject handle to enhacement (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = handles.file;
a =imread(file);
[r c p]=size(a); % If it is color, convert to gray....
if p==3
a=rgb2gray(a);
end
b=histeq(a); % Applying the Histogram
imwrite(b,'enhanced.bmp');
axes(handles.axes2);
imshow(b);
% --- Executes on button press in thresh.
function thresh_Callback(hObject, eventdata, handles)
% hObject handle to thresh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = handles.file;
a=imread(file);
[r c p]=size(a);
b=a;
if p==3
b=rgb2gray(a);
end
Out =zeros(r,c);
for i=1:r
for j=1:c
if b(i,j) >150
Out(i,j)=1;
else
Out(i,j)=0;
end
end
end
axes(handles.axes2);
imshow(Out);
imwrite(Out,'thresholded.bmp');
% --- Executes on button press in erosion.
function erosion_Callback(hObject, eventdata, handles)
% hObject handle to erosion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = handles.file;
Out=imread(file);
B1 = medfilt2(Out,[5 5]);
axes(handles.axes2);
imshow(B1);
imwrite(B1,'eroded.bmp');
% --- Executes on button press in holefill.
function holefill_Callback(hObject, eventdata, handles)
% hObject handle to holefill (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = handles.file;
bw1=imread(file);
BW15 = imfill(bw1,8,'holes');
axes(handles.axes2);
imshow(BW15);
BW15=uint8(BW15);
imwrite(BW15,'FILLED.bmp');
uiwait(msgbox('Process completed','Hole filling Status','modal'));
% --- Executes on button press in segment.
function segment_Callback(hObject, eventdata, handles)
% hObject handle to segment (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = handles.file;
file=imread(file);
J = imcomplement(file);
figure(1);
imshow(J);
J=bwmorph(J,'FILL');
figure(2);
imshow(J);
[r1 c1]=size(J); %%Here B&W image
[L2 NUM2] = bwlabel(J);
disp(NUM2);
removed=0;
STATS = regionprops(L2,'area'); %Finds the number of pixels on each region
aA=[STATS.Area]; %Conversion from structure to array
for j=1:1:NUM2
bw= aA(j);
if bw <1500
L2(L2==j)=0;
removed = removed + 1;
end
end
NUM2=NUM2-removed;
[L3 NUM3] = bwlabel(L2);
STATS = regionprops(L3,'area');
disp(NUM3);
stats1 = regionprops(L3, 'PixelList'); %getting the pixel co-ordinates
CC=[];
for j=1:1:NUM3 %NUM3
aA1=stats1(j);
CC{j} = [aA1.PixelList]; %Conversion from structure to array
end
removed1=0;
tmp = [];
for j=1:NUM3 % THIS LOOP FORMS THE TRI_ANGLE
tmp = CC{j}(:);
B=find(tmp(:,1)==1);%%%%%%%%%
disp(B);
if isempty(B)
imshow(L3==j);
else
L3(L3==j)=0;
removed1=removed1+1;
end
end
NUM3=NUM3-removed1;
disp(NUM3);
[L4 NUM4] = bwlabel(L3);
for i=1:NUM4
[r,c] = find(L4 == i);
BW2 = bwselect(L3,c,r,4);
imwrite(BW2,'SEGMENTED.BMP');
end
% figure(7);
% imshow(L4);
if NUM4~=0
Image=BW2;
th1=1;
th2=0;
[rows columns]=size(Image);
len=rows;
Rimage = Image;
OutputImage=ones(rows,columns);
Boundary_Pixel=[];
%detecting ones
h = waitbar(0,'Please wait...');
index=1;
for y= 1:columns
for x=1:rows
%for left top corner
if (x==1 & y==1)
if (Rimage(x, y+1)==th1)
if (Rimage(x+1, y+1)==th1)
if (Rimage(x+1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for right top corner
elseif (x==1 & y==len)
if (Rimage(x+1, y)==th1)
if (Rimage(x+1, y-1)==th1)
if (Rimage(x,y-1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for bottom left corner[2,3,4]
elseif (x==len & y==1)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y+1) ==th1)
if (Rimage(x,y+1) ==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for bottom right corner[8,1,2]
elseif (x==len & y==len)
if (Rimage(x, y-1)==th1)
if (Rimage(x-1, y-1)==th1)
if (Rimage(x-1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for top edge[8,7,6,5,4]
elseif (x==1)
if (Rimage(x, y-1)==th1)
if (Rimage(x+1, y-1)==th1)
if (Rimage(x+1, y)==th1)
if (Rimage(x+1, y+1)==th1)
if (Rimage(x,y+1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for right edge[2,1,8,7,6]
elseif (y==len)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y-1)==th1)
if (Rimage(x, y-1)==th1)
if (Rimage(x+1, y-1)==th1)
if (Rimage(x+1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for bottom edge[8,1,2,3,4]
elseif (x==len)
if (Rimage(x, y-1)==th1)
if (Rimage(x-1, y-1)==th1)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y+1)==th1)
if (Rimage(x,y+1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for left edge[2,3,4,5,6]
elseif (y==1)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y+1)==th1)
if (Rimage(x, y+1)==th1)
if (Rimage(x+1, y+1)==th1)
if (Rimage(x+1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for remaining pixels
else
if (Rimage(x-1,y-1)==th1)
if (Rimage(x-1,y)==th1)
if (Rimage(x-1,y+1)==th1)
if (Rimage(x,y+1)==th1)
if (Rimage(x+1,y+1)==th1)
if (Rimage(x+1,y)==th1)
if (Rimage(x+1,y-1)==th1)
if (Rimage(x,y-1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
end
end
end
end
end
end
% figure(221);
% imshow(OutputImage);
%detecting zeros
index=1;
for y=1:columns
for x=1:rows
%for left top corner[4,5,6]
if (x==1 & y==1)
if (Rimage(x, y+1)==th2)
if (Rimage(x+1, y+1)==th2)
if (Rimage(x+1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for right top corner[8,7,6]
elseif (x==1 & y==len)
if (Rimage(x+1, y)==th2)
if (Rimage(x+1, y-1)==th2)
if (Rimage(x,y-1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for bottom left corner[2,3,4]
elseif (x==len & y==1)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y+1) ==th2)
if (Rimage(x,y+1) ==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for bottom right corner[8,1,2]
elseif (x==len & y==len)
if (Rimage(x, y-1)==th2)
if (Rimage(x-1, y-1)==th2)
if (Rimage(x-1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
%for top edge[8,7,6,5,4]
elseif (x==1)
if (Rimage(x, y-1)==th2)
if (Rimage(x+1, y-1)==th2)
if (Rimage(x+1, y)==th2)
if (Rimage(x+1, y+1)==th2)
if (Rimage(x,y+1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for right edge[2,1,8,7,6]
elseif (y==len)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y-1)==th2)
if (Rimage(x, y-1)==th2)
if (Rimage(x+1, y-1)==th2)
if (Rimage(x+1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for bottom edge[8,1,2,3,4]
elseif (x==len)
if (Rimage(x, y-1)==th2)
if (Rimage(x-1, y-1)==th2)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y+1)==th2)
if (Rimage(x,y+1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for left edge[2,3,4,5,6]
elseif (y==1)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y+1)==th2)
if (Rimage(x, y+1)==th2)
if (Rimage(x+1, y+1)==th2)
if (Rimage(x+1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
%for remaining pixels
else
if (Rimage(x-1,y-1)==th2)
if (Rimage(x-1,y)==th2)
if (Rimage(x-1,y+1)==th2)
if (Rimage(x,y+1)==th2)
if (Rimage(x+1,y+1)==th2)
if (Rimage(x+1,y)==th2)
if (Rimage(x+1,y-1)==th2)
if (Rimage(x,y-1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
end
end
end
end
waitbar(y/columns,h)
end
end
close(h);
% figure(224);
% imshow(OutputImage);
% DETECTION OF BOUNDARY DETECTED IMAGE
% imshow(OutputImage)
imwrite(OutputImage,'Bound1.bmp');
% save a
% load a
Out1=OutputImage;
[m n]=size(Out1);
Out2=zeros(m,n);
for i=1:m
for j=1:n
if Out1(i,j)>=1
Out2(i,j)=255;
end
end
end
index=1;
for x = 1:256
for y=1:256
bb=Out2(x,y);
if bb>=10
Boundary_Pixel{index}=[x,y];
X1(index)=x;
Y1(index)=y;
index=index+1;
end
end
end
% save a1
% load a1
X = X1; %X co-ordinates
Y =Y1; %Y co-ordinates
% XAA = X1;
% YAA =Y1;
save X X
save Y Y
X1=X;
Y1 =Y;
XB=X;
YB =Y;
Xmin = min(XB)
[Ymin Ind] = min(YB) %FIND OUT THE CORNER FIRST POINTS OF TRI_ANGLE
Dec=X(Ind)
Xmax = max(XB);
Ymax = max(YB);
[Ymax Ind] = max(YB);
Dec1=X(Ind);
axes(handles.axes2);
% X = [Xmin Xmax];
X = [Dec Dec1];
Y = [Ymin Ymax];
line(Y,X) ;
X = [Dec Dec];
Y = [Ymin Ymax];
line(Y,X) ;
X = [Dec Dec1];
Y = [Ymax Ymax];
line(Y,X) ;
X = [Dec Xmax];
Y = [Ymax Ymax];
line(Y,X) ;
X = [Dec Xmax];
Y = [Ymin Ymax];
b=ones(256,256);
line(Y,X) ;
handles.Xmin=Xmin;
handles.Xmax=Xmax;
handles.Dec=Dec;
handles.Dec1=Dec1;
handles.Ymin=Ymin;
handles.Ymax=Ymax;
else
bb='0'
set(handles.ANGLE,'String',bb);
warndlg('anterior chamber is almost closed ... glaucoma detected..no further processing');
bb='GLAUCOMA DETECTED'
set(handles.STATUS1,'String',bb);
disp('no anterior chamber');
end
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in mask.
function mask_Callback(hObject, eventdata, handles)
% hObject handle to mask (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Xmin=get(handles.Xmin);
Xmax=get(handles.Xmax);
Dec =handles.Dec;
Dec1 =handles.Dec1;
Ymin =handles.Ymin;
Ymax =handles.Ymax;
file = handles.file;
aa=imread(file);
%%%%%%%%%%%%%%%%%%%CALCUATING BOUNDNG BOX
X1=Ymin;
Y1=Dec;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LTX1=X1-25;
LTY1=Y1-25;
RTX1=X1-25;
RTY1=Y1+25;
LBX1=X1+25;
LBY1=Y1-25;
RBX1=X1+25;
RBY1=Y1+25;
ROIIMAGE11=aa(LTY1:RBY1,LTX1:LBX1);
axes(handles.axes2);
imshow(ROIIMAGE11);
imwrite(ROIIMAGE11,'masked.bmp');
% --- Executes on button press in aod.
function aod_Callback(hObject, eventdata, handles)
% hObject handle to aod (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file=handles.file;
a=imread(file);
a=uint8(a);
b=histeq(a);
figure(2);
imshow(b);
%pixval on;
[r c]=size(a);
for i=1:r
for j=1:c
if b(i,j) >50
aOut2(i,j)=1;
aOut21(i,j)=0;
else
aOut2(i,j)=0;
aOut21(i,j)=1;
end
end
end
aOut22 = imcomplement(imfill(imcomplement(aOut2),'holes'));
% imshow(aOut22);
aOut22 = imfill(aOut22,'holes');
aJ2 = imcomplement(aOut22);
% INVERTED IMAGE
[L2 NUM2] = bwlabel(aJ2);
% disp(NUM2);
removed=0;
removed1=0;
STATS = regionprops(L2,'area');
%STATS1 = imfeature(L2,'all');
aA=[STATS.Area];
for j=1:1:NUM2
bw= aA(j);
if bw <150
L2(L2==j)=0;
removed = removed + 1;
end
end
NUM2=NUM2-removed;
[L3 NUM3] = bwlabel(L2);
imshow(L3==1);
[r,c] = find(L3 == 1);
% figure;
BW2 = bwselect(L3,c,r,4);
% a=imread(filename);
Image=BW2;
imshow(Image);
% pixval on;
th1=1;
th2=0;
[rows columns]=size(Image);
len=rows;
Rimage = Image;
j=columns;
Num=[];
index1=1;
for i=1:r
if Image(i,j)==1
Boundary_Pixel_1{index1}=[i,j];
Num(index1)=i;
index1=index1+1;
end
end
Mini=min(Num);
Maxi=max(Num);
OutputImage=ones(rows,columns);
Boundary_Pixel=[];
% Boundary_y=[];
% detecting ones
h = waitbar(0,'Please wait...');
index=1;
for y= 1:columns
for x=1:rows
% for left top corner[4,5,6]
if (x==1 & y==1)
if (Rimage(x, y+1)==th1)
if (Rimage(x+1, y+1)==th1)
if (Rimage(x+1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for right top corner[8,7,6]
elseif (x==1 & y==len)
if (Rimage(x+1, y)==th1)
if (Rimage(x+1, y-1)==th1)
if (Rimage(x,y-1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for bottom left corner[2,3,4]
elseif (x==len & y==1)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y+1) ==th1)
if (Rimage(x,y+1) ==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for bottom right corner[8,1,2]
elseif (x==len & y==len)
if (Rimage(x, y-1)==th1)
if (Rimage(x-1, y-1)==th1)
if (Rimage(x-1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for top edge[8,7,6,5,4]
elseif (x==1)
if (Rimage(x, y-1)==th1)
if (Rimage(x+1, y-1)==th1)
if (Rimage(x+1, y)==th1)
if (Rimage(x+1, y+1)==th1)
if (Rimage(x,y+1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
% for right edge[2,1,8,7,6]
elseif (y==len)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y-1)==th1)
if (Rimage(x, y-1)==th1)
if (Rimage(x+1, y-1)==th1)
if (Rimage(x+1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
% for bottom edge[8,1,2,3,4]
elseif (x==len)
if (Rimage(x, y-1)==th1)
if (Rimage(x-1, y-1)==th1)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y+1)==th1)
if (Rimage(x,y+1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
% for left edge[2,3,4,5,6]
elseif (y==1)
if (Rimage(x-1, y)==th1)
if (Rimage(x-1, y+1)==th1)
if (Rimage(x, y+1)==th1)
if (Rimage(x+1, y+1)==th1)
if (Rimage(x+1,y)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
else
% for remaining pixels
if (Rimage(x-1,y-1)==th1)
if (Rimage(x-1,y)==th1)
if (Rimage(x-1,y+1)==th1)
if (Rimage(x,y+1)==th1)
if (Rimage(x+1,y+1)==th1)
if (Rimage(x+1,y)==th1)
if (Rimage(x+1,y-1)==th1)
if (Rimage(x,y-1)==th1)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
end
end
end
end
end
end
%detecting zeros
index=1;
for y=1:columns
for x=1:rows
% for left top corner[4,5,6]
if (x==1 & y==1)
if (Rimage(x, y+1)==th2)
if (Rimage(x+1, y+1)==th2)
if (Rimage(x+1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for right top corner[8,7,6]
elseif (x==1 & y==len)
if (Rimage(x+1, y)==th2)
if (Rimage(x+1, y-1)==th2)
if (Rimage(x,y-1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for bottom left corner[2,3,4]
elseif (x==len & y==1)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y+1) ==th2)
if (Rimage(x,y+1) ==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for bottom right corner[8,1,2]
elseif (x==len & y==len)
if (Rimage(x, y-1)==th2)
if (Rimage(x-1, y-1)==th2)
if (Rimage(x-1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
% for top edge[8,7,6,5,4]
elseif (x==1)
if (Rimage(x, y-1)==th2)
if (Rimage(x+1, y-1)==th2)
if (Rimage(x+1, y)==th2)
if (Rimage(x+1, y+1)==th2)
if (Rimage(x,y+1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
% for right edge[2,1,8,7,6]
elseif (y==len)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y-1)==th2)
if (Rimage(x, y-1)==th2)
if (Rimage(x+1, y-1)==th2)
if (Rimage(x+1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
% for bottom edge[8,1,2,3,4]
elseif (x==len)
if (Rimage(x, y-1)==th2)
if (Rimage(x-1, y-1)==th2)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y+1)==th2)
if (Rimage(x,y+1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
% for left edge[2,3,4,5,6]
elseif (y==1)
if (Rimage(x-1, y)==th2)
if (Rimage(x-1, y+1)==th2)
if (Rimage(x, y+1)==th2)
if (Rimage(x+1, y+1)==th2)
if (Rimage(x+1,y)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
else
% for remaining pixels
if (Rimage(x-1,y-1)==th2)
if (Rimage(x-1,y)==th2)
if (Rimage(x-1,y+1)==th2)
if (Rimage(x,y+1)==th2)
if (Rimage(x+1,y+1)==th2)
if (Rimage(x+1,y)==th2)
if (Rimage(x+1,y-1)==th2)
if (Rimage(x,y-1)==th2)
Boundary_Pixel{index}=[x,y];
OutputImage(x,y)=0;
index=index+1;
end
end
end
end
end
end
end
end
end
waitbar(y/columns,h)
end
end
close(h);
% DETECTION OF BOUNDARY DETECTED IMAGE
% imshow(OutputImage)
% imwrite(OutputImage,'Bound1.bmp')
Out1=OutputImage;
[m n]=size(Out1);
% pixval on
Out2=zeros(m,n);
for i=1:m
for j=1:n
if Out1(i,j)>=1
Out2(i,j)=255;
end
end
end
% imshow(Out2,[]);
% pixval on
index=1;
threshold=255;
for x = 1:rows
for y=1:columns
bb=Out2(x,y);
if bb>=10
Boundary_Pixel{index}=[x,y];
X1(index)=x;
Y1(index)=y;
index=index+1;
end
end
end
save a11
load a11
%
% X = X1;
% Y =Y1;
% XAA = X1;
% YAA =Y1;
%
% save XAA XAA
% save YAA YAA
%
X1=X;
Y1 =Y;
XB=X;
YB =Y;
Xmin = min(XB);
[Ymin Ind] = min(YB);
Dec=X(Ind);
Xmax = max(XB);
Ymax = max(YB);
[Ymax Ind] = max(YB);
Dec1=X(Ind);
aa=imread(file);
axes(handles.axes2);
imshow(aa);
% X = [Xmin Xmax];
X = [Dec Mini];
Y = [Ymin Ymax];
line(Y,X) ;
X = [Dec Dec];
Y = [Ymin Ymax];
line(Y,X) ;
X = [Dec Dec1];
Y = [Ymax Ymax];
line(Y,X) ;
X = [Dec Xmax];
Y = [Ymax Ymax];
line(Y,X) ;
X = [Dec Maxi];
Y = [Ymin Ymax];
b=ones(256,256);
line(Y,X) ;
% pixval on
Distance1=sqrt((Dec-Mini)^2+(Ymin-Ymax)^2);%opposite of traingle 1hyp
disp(Distance1);
Distance2=sqrt((Dec-Maxi)^2+(Ymin-Ymax)^2);%opposite of traingle 1hyp2
disp(Distance2);
Distance3=sqrt((Dec-Dec)^2+(Ymin-Ymax)^2);%adjacet of traingle 1
disp(Distance3);
%tan=opp/adj
Thete1=acos(Distance3/Distance1);
Thete2=acos(Distance3/Distance2);
AA=Thete1+Thete2;
BB=(180/pi)*AA;
% Thete=atan(Distance1/Distance3);
% Theta=acos(adjacent/hyp);
Theta1=(180/pi)*Thete1;
Theta2=(180/pi)*Thete2;
disp(Theta1);
disp(Theta2);
% Theta=Theta1-Theta2;
Theta3=Theta1-Theta2;
Theta13=num2str(Theta3);
set(handles.ANGLE,'String',Theta13);
% disp(Theta);
Theta3=round(Theta3);
if Theta3 > 19
bb='NORMAL EYE'
set(handles.STATUS1,'String',bb);
else
bb='GLAUCOMA DETECTED'
set(handles.STATUS1,'String',bb);
end
% --- Executes on button press in radian.
function radian_Callback(hObject, eventdata, handles)
% hObject handle to radian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radian
% --- Executes on button press in togglebutton2.
function togglebutton2_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton2
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
display('clicked')
elseif button_state == get(hObject,'Min')
display('rleased');
end
After running this code .. i am getting some errors. Please help. The errors are:
- Error in gui_mainfcn (line 95)
- feval(varargin{:});
- Error in Glaucoma_Detection (line 42)
- gui_mainfcn(gui_State, varargin{:});
- Error in Glaucoma_Detection>mask_Callback (line 779)
- Xmin=get(handles.Xmin);
댓글 수: 3
Walter Roberson
2018년 4월 20일
attach your .m and your .fig file so we can test.
Also attach the image files that you read in -- I see that your open callback always reads an image file.
khushboo chhikara
2018년 4월 20일
khushboo chhikara
2018년 4월 20일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Contrast Adjustment에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
