the second call back function does not work in gui .could any one help me?
Show older comments
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.bmp';'*.jpg';'*.gif';'*.*'}, 'Pick an Image File');
S = imread([pathname,filename]);
axes(handles.axes1);
imshow(S);
handles.f=[pathname,filename];
guidata(hObject, handles);
figure1.text = 'image uploaded'
% --- Executes on button press in pushbutton2.
function process_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isfield(handles, 'f')
imread = handles.f;
% convert to binary
binary_image=im2bw(imread('handles.f'));
%Small region is taken to show output clear
binary_image = binary_image(120:400,20:250);
figure;imshow(binary_image);title('Input image');
Accepted Answer
More Answers (1)
Walter Roberson
on 26 Jun 2017
if isfield(handles, 'f')
% convert to binary
binary_image = im2bw( imread(handles.f) );
%Small region is taken to show output clear
binary_image = binary_image(120:400,20:250);
figure;
imshow(binary_image);
title('Input image');
end
23 Comments
indrani dalui
on 26 Jun 2017
Walter Roberson
on 26 Jun 2017
Attach your code and your .fig file.
indrani dalui
on 26 Jun 2017
indrani dalui
on 26 Jun 2017
Walter Roberson
on 26 Jun 2017
You did not have a button with tag 'process': the tag for the button was still 'pushbutton2'. Files attached.
indrani dalui
on 27 Jun 2017
indrani dalui
on 27 Jun 2017
Walter Roberson
on 27 Jun 2017
imshow(DataForFirstImage, 'Parent', handles.AxesForFirstImage);
imshow(DataForSecondImage, 'Parent', handles.AxesForSecondImage);
indrani dalui
on 28 Jun 2017
Edited: Walter Roberson
on 28 Jun 2017
Walter Roberson
on 28 Jun 2017
% --- Executes on button press in Browse.
function Browse_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.bmp';'*.jpg';'*.gif';'*.*'}, 'Pick an Image File');
if isnumeric(filename); return; end %user cancelled
fullname = fullfile(pathname, filename);
S = imread(fullname);
imshow(S, 'Parent', handles.axes1);
handles.f = fullname;
bw = im2bw(S);
imshow(S, 'Parent', handles.axes2);
guidata(hObject, handles);
indrani dalui
on 29 Jun 2017
Walter Roberson
on 29 Jun 2017
Which two images are to be drawn on the axes? Do you want to prompt the user for a second file? If so then just do so by copying the code you use to prompt for the first file.
Are you going to save both file names to handles? If so then what should be the name for the second one? Or should handles.f become a 1 x 2 cell array of strings containing both names?
indrani dalui
on 29 Jun 2017
Walter Roberson
on 29 Jun 2017
% --- Executes on button press in Browse.
function Browse_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.bmp';'*.jpg';'*.gif';'*.*'}, 'Pick First Image File');
if isnumeric(filename); return; end %user cancelled
fullname = fullfile(pathname, filename);
S = imread(fullname);
imshow(S, 'Parent', handles.axes1);
handles.f = fullname;
[filename, pathname] = uigetfile({'*.bmp';'*.jpg';'*.gif';'*.*'}, 'Pick Second Image File');
if isnumeric(filename); return; end %user cancelled
fullname = fullfile(pathname, filename);
S = imread(fullname);
imshow(S, 'Parent', handles.axes2);
handles.f2 = fullname;
guidata(hObject, handles);
indrani dalui
on 29 Jun 2017
indrani dalui
on 29 Jun 2017
Edited: Walter Roberson
on 29 Jun 2017
indrani dalui
on 29 Jun 2017
Walter Roberson
on 29 Jun 2017
"after previous process i want to convert those image to binary form and result will show with in same axes or window"
So don't call figure() then. figure() creates a new window. Just imshow() with 'Parent' set to the axes you have already created for the output.
indrani dalui
on 29 Jun 2017
Walter Roberson
on 29 Jun 2017
Look again. I coded
imshow(S, 'Parent', handles.axes1);
The first parameter is the data to display. Then the two items after that are a Name/Value pair that indicates that the imshow is to create an image whose parent axes is handles.axes1 . You change the line to
imshow('Parent');
which does not pass in an array of data and does not name an axes. When you use that particular syntax, it happens that imshow will interpret the string 'Parent' as being the file name of an image it is being asked to display.
You should be using something like
ax = handles.axes1;
imshow(thin_image, 'Parent', ax);
title(ax, 'Thinned Image');
indrani dalui
on 29 Jun 2017
indrani dalui
on 29 Jun 2017
Edited: Walter Roberson
on 29 Jun 2017
Walter Roberson
on 29 Jun 2017
I don't know. I do not do fingerprint work.
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!