the second call back function does not work in gui .could any one help me?

% --- 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');

 採用された回答

Jan
Jan 2017 年 6 月 26 日
編集済み: Jan 2017 年 6 月 26 日
  • Please do not only state "does not work", but explain what you see. do you get an error message or do the results differ from your expectations?
function process_Callback(hObject, eventdata, handles)
if isfield(handles, 'myImage')
myImage = handles.f;
binary_image=im2bw(imread('handles.f'));
Now the image with the name 'handles.f' is loaded, but you want:
binary_image=im2bw(imread(handles.f));
without quotes. The error message should reveal this directly. Note that Walter has mentioned this already, so please update your code.
  • The purpose of the figure1.text = 'image uploaded' lines is not clear to me.
  • Simplification:
% Replace this:
e=1;
for k=x-n:x+n
f=1;
for l=y-n:y+n
mat(e,f)=temp(k,l);
f=f+1;
end
e=e+1;
end;
% By this:
mat(1:2*n + 1,1:2*n+1) = temp(x-n:x+n, y-n:y+n);
% Or even better:
mat = temp(x-n:x+n, y-n:y+n);

6 件のコメント

indrani dalui
indrani dalui 2017 年 6 月 26 日
yes sir i want binary_image=im2bw(imread(handles.f) that image convert to binary form...
indrani dalui
indrani dalui 2017 年 6 月 27 日
編集済み: indrani dalui 2017 年 6 月 27 日
yes sir i want binary_image=im2bw(imread(handles.f) that image convert to binary form.....but error will occur ...please tell me how to that image convert into binary and extract Minutiae ..i am attached .m file and .flg file .please sir help me.
Jan
Jan 2017 年 6 月 28 日
"error will occur" is not useful to describe the problem. Please post the complete error message.
indrani dalui
indrani dalui 2017 年 6 月 28 日
that problem is solved sir..thank you for your guidance
indrani dalui
indrani dalui 2017 年 7 月 1 日
編集済み: Walter Roberson 2017 年 7 月 1 日
sir,after two images output i want compare both two images ..is similar or not within one push button... code is bellow.what to do sir?
% --- Executes on button press in Recognation.
function Recognation_Callback(hObject, eventdata, ~)
% hObject handle to Recognation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isequal(f,f2) % f and f2 are compared
msgbox('Both f and f2 are equal', 'MESSAGE');
else
msgbox('f and f2 are not equal', 'MESSAGE');
end
Walter Roberson
Walter Roberson 2017 年 7 月 1 日
f and f2 are not defined in your function Recognation_Callback

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 6 月 26 日
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 件のコメント

indrani dalui
indrani dalui 2017 年 6 月 26 日
it is not process sir or call the function
Walter Roberson
Walter Roberson 2017 年 6 月 26 日
Attach your code and your .fig file.
indrani dalui
indrani dalui 2017 年 6 月 26 日
respected sir bellow attached .flg & code also
indrani dalui
indrani dalui 2017 年 6 月 26 日
sir i am sending u my code and .flg file please do needful.
Walter Roberson
Walter Roberson 2017 年 6 月 26 日
You did not have a button with tag 'process': the tag for the button was still 'pushbutton2'. Files attached.
indrani dalui
indrani dalui 2017 年 6 月 27 日
thank you sir ...now it's work
indrani dalui
indrani dalui 2017 年 6 月 27 日
sir i create a GUI where are two axes , i want to upload two different images with help of one pushbutton ..how could i do sir.please help me.
imshow(DataForFirstImage, 'Parent', handles.AxesForFirstImage);
imshow(DataForSecondImage, 'Parent', handles.AxesForSecondImage);
indrani dalui
indrani dalui 2017 年 6 月 28 日
編集済み: Walter Roberson 2017 年 6 月 28 日
where i put this code sir
i attached the code bellow
% --- Executes on button press in Browse.
function Browse_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);
% --- 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
indrani dalui 2017 年 6 月 29 日
sir in previous code ...when i brows image .the same image are upload both axes but i want when i click brows button then two different image upload in different axes..
Walter Roberson
Walter Roberson 2017 年 6 月 29 日
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
indrani dalui 2017 年 6 月 29 日
sir both are input image the image choose from file,the image either same or different and also want to prompt the user for a second file.if i am save the file with different handler name then what should i do sir?
% --- 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
indrani dalui 2017 年 6 月 29 日
thank you sir...it's work.
indrani dalui
indrani dalui 2017 年 6 月 29 日
編集済み: Walter Roberson 2017 年 6 月 29 日
after previous process i want to convert those image to binary form and result will show with in same axes or window ...both of two images with help of one process button.the code is
function Process_Callback(hObject, eventdata, handles)
% 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)
if isfield(handles, 'f')
% convert to binary
binary_image = im2bw( imread(handles.f) );
%Thinning
thin_image=~bwmorph(binary_image,'thin',Inf);
figure;imshow(thin_image);title('Thinned Image');
%Minutiae extraction
s=size(thin_image);
N=3;%window size
n=(N-1)/2;
r=s(1)+2*n;
c=s(2)+2*n;
double temp(r,c);
temp=zeros(r,c);bifurcation=zeros(r,c);ridge=zeros(r,c);
temp((n+1):(end-n),(n+1):(end-n))=thin_image(:,:);
outImg=zeros(r,c,3);%For Display
outImg(:,:,1) = temp .* 255;
outImg(:,:,2) = temp .* 255;
outImg(:,:,3) = temp .* 255;
for x=(n+1+10):(s(1)+n-10)
for y=(n+1+10):(s(2)+n-10)
e=1;
for k=x-n:x+n
f=1;
for l=y-n:y+n
mat(e,f)=temp(k,l);
f=f+1;
end
e=e+1;
end;
if(mat(2,2)==0)
ridge(x,y)=sum(sum(~mat));
bifurcation(x,y)=sum(sum(~mat));
end
end;
end;
% RIDGE END FINDING
[ridge_x ridge_y]=find(ridge==2);
len=length(ridge_x);
%For Display
for i=1:len
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)-3),2:3)=0;
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)+3),2:3)=0;
outImg((ridge_x(i)-3),(ridge_y(i)-3):(ridge_y(i)+3),2:3)=0;
outImg((ridge_x(i)+3),(ridge_y(i)-3):(ridge_y(i)+3),2:3)=0;
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)-3),1)=255;
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)+3),1)=255;
outImg((ridge_x(i)-3),(ridge_y(i)-3):(ridge_y(i)+3),1)=255;
outImg((ridge_x(i)+3),(ridge_y(i)-3):(ridge_y(i)+3),1)=255;
end
%BIFURCATION FINDING
[bifurcation_x bifurcation_y]=find(bifurcation==4);
len=length(bifurcation_x);
%For Display
for i=1:len
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)-3),1:2)=0;
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)+3),1:2)=0;
outImg((bifurcation_x(i)-3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),1:2)=0;
outImg((bifurcation_x(i)+3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),1:2)=0;
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)-3),3)=255;
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)+3),3)=255;
outImg((bifurcation_x(i)-3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),3)=255;
outImg((bifurcation_x(i)+3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),3)=255;
end
figure;imshow(outImg);title('Minutiae');
end
indrani dalui
indrani dalui 2017 年 6 月 29 日
respected sir i attached my m file ...i want when i am clicking the process button the two image will show there result on that axes or window not other window will shown individually..one more things axes 1 image result shows but axes 2 image result not shown ..what to do sir?
Walter Roberson
Walter Roberson 2017 年 6 月 29 日
"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
indrani dalui 2017 年 6 月 29 日
sir ,i remove the figure().and write there imshow('Parent') ..but error will occur bellow the error message
>> new Error using getImageFromFile (line 11) Cannot find the specified file: "Parent".
Error in imageDisplayParseInputs (line 73) [common_args.CData,common_args.Map] = ...
Error in imshow (line 219) [common_args,specific_args] = ...
Error in new>Process_Callback (line 110) imshow('Parent');title('Thinned Image');
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in new (line 45) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)new('Process_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
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
indrani dalui 2017 年 6 月 29 日
thank you
indrani dalui
indrani dalui 2017 年 6 月 29 日
編集済み: Walter Roberson 2017 年 6 月 29 日
sir,after extraction minutiae how to count ridge-end and bifurcation point and location instead of bellow code..
function Process_Callback(hObject, eventdata, handles)
% 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)
if isfield(handles, 'f')
% convert to binary
binary_image = im2bw( imread(handles.f) );
%Thinning
thin_image=~bwmorph(binary_image,'thin',Inf);
figure;imshow(thin_image);title('Thinned Image');
%Minutiae extraction
s=size(thin_image);
N=3;%window size
n=(N-1)/2;
r=s(1)+2*n;
c=s(2)+2*n;
double temp(r,c);
temp=zeros(r,c);bifurcation=zeros(r,c);ridge=zeros(r,c);
temp((n+1):(end-n),(n+1):(end-n))=thin_image(:,:);
outImg=zeros(r,c,3);%For Display
outImg(:,:,1) = temp .* 255;
outImg(:,:,2) = temp .* 255;
outImg(:,:,3) = temp .* 255;
for x=(n+1+10):(s(1)+n-10)
for y=(n+1+10):(s(2)+n-10)
e=1;
for k=x-n:x+n
f=1;
for l=y-n:y+n
mat(e,f)=temp(k,l);
f=f+1;
end
e=e+1;
end;
if(mat(2,2)==0)
ridge(x,y)=sum(sum(~mat));
bifurcation(x,y)=sum(sum(~mat));
end
end;
end;
% RIDGE END FINDING
[ridge_x ridge_y]=find(ridge==2);
len=length(ridge_x);
%For Display
for i=1:len
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)-3),2:3)=0;
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)+3),2:3)=0;
outImg((ridge_x(i)-3),(ridge_y(i)-3):(ridge_y(i)+3),2:3)=0;
outImg((ridge_x(i)+3),(ridge_y(i)-3):(ridge_y(i)+3),2:3)=0;
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)-3),1)=255;
outImg((ridge_x(i)-3):(ridge_x(i)+3),(ridge_y(i)+3),1)=255;
outImg((ridge_x(i)-3),(ridge_y(i)-3):(ridge_y(i)+3),1)=255;
outImg((ridge_x(i)+3),(ridge_y(i)-3):(ridge_y(i)+3),1)=255;
end
%BIFURCATION FINDING
[bifurcation_x bifurcation_y]=find(bifurcation==4);
len=length(bifurcation_x);
%For Display
for i=1:len
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)-3),1:2)=0;
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)+3),1:2)=0;
outImg((bifurcation_x(i)-3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),1:2)=0;
outImg((bifurcation_x(i)+3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),1:2)=0;
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)-3),3)=255;
outImg((bifurcation_x(i)-3):(bifurcation_x(i)+3),(bifurcation_y(i)+3),3)=255;
outImg((bifurcation_x(i)-3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),3)=255;
outImg((bifurcation_x(i)+3),(bifurcation_y(i)-3):(bifurcation_y(i)+3),3)=255;
end
figure;imshow(outImg);title('Minutiae');
end
Walter Roberson
Walter Roberson 2017 年 6 月 29 日
I don't know. I do not do fingerprint work.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by