Professional Documents
Culture Documents
output=hObject;
[a b]=uigetfile({'*.*'});
img=imread([b a]);
grayy=rgb2gray(img);
gr=graythresh(grayy);
handles.bw=im2bw(grayy,gr);
imshow(handles.bw,'Parent',handles.axes1);
guidata(hObject,handles);
handles.output=hObject;
inverse_binary=not(handles.bw);
[handles.L handles.Num_object]=bwlabel(inverse_binary);
set(handles.text2,'string',handles.Num_object);
imshow(handles.L,'Parent',handles.axes2);
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = Sample_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)
handles.output=hObject;
gg=handles.bw;
BW= imbinarize(gg);
BW2 = bwareaopen(BW, 500);
BW3=bwareaopen(BW, 270);
BW4=bwareaopen(BW, 50);
%%set(handles.text2,'string',handles.Num_object);
imshow(BW3,'Parent',handles.axes1);