function varargout = ui(varargin)
% Edit the above text to modify the response to help ui
% Last Modified by GUIDE v2.5 20-Jun-2017 16:16:26
% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ui_OpeningFcn, ... 'gui_OutputFcn', @ui_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
% --- Executes just before ui is made visible. function ui_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles);
% UIWAIT makes ui wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = ui_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;
figure1.text = 'upload image'
% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) [filename, pathname] = uigetfile({'*.bmp';'*.jpg';'*.gif';'*.*'}, 'Pick an Image File'); S = imread([pathname,filename]); axes(handles.axes1); imshow(S); handles.myimage=[pathname,filename]; guidata(hObject, handles); figure1.text = 'image uploaded'
% --- Executes during object creation, after setting all properties. function axes1_CreateFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
% --- Executes on button press in pushbutton3. function readimage_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
[filename,pathname,filterindex] = uigetfile(); handles.myImage = imread(fullfile(pathname, filename)); guidata(hObject, handles); a = uigetfile(); filename = a; setappdata(0,'filename',filename);
if filename == -1 error('Failed to open file.') msgbox('Failed to open file.'); end
a = imread(a); % if isequal(filename,0) isequal(pathname,0) % disp('User pressed cancel') % else % disp(['User selected ', fullfile(pathname, filename)])
axes(handles.axesimg); imshow(a); setappdata(0,'a',a); setappdata(0,'filename',a); assignin('base','a',a); plot(handles.axesimg,'a') %handles.f = [filename]; %guidata(object_handle,handles); disp('Reading the image into variable X'); [X,map] = imread(filename); assignin('base','X',X); assignin('base','map',map);
assignin('base','width',200); assignin('base','height',200);
edittimes.Visible = 'off';
function process_Callback(hObject, eventdata, handles) if isfield(handles, 'myImage') myImage = handles.myImage; % hObject handle to process (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
%convert input image to binary binary_image=im2bw(imread('s'));
%Small region is taken to show output clear binary_image = binary_image(120:400,20:250); figure;imshow(binary_image);title('Input image') end