Hey, Im trying to build a GUI for the Quality Assessment tools of an X-Ray machine. In this , i have to load an image and then do various operations on it. I have created a push button to load my image and another push button to do operations on it. I have to send the image from the callback of the Load Push Button to the callback of the push button of the Operations. Please help me how to do this! Thanks a lot.
Gaurav

 채택된 답변

Chandra Kurniawan
Chandra Kurniawan 2012년 1월 10일

0 개 추천

Hi,
In callback of Load Push Button you should write like this :
handles.output = hObject;
[fn pn] = uigetfile('*.jpg','select image');
if fn ~= 0
handles.I = imread(fullfile(pn,fn));
imshow(handles.I);
end
guidata(hObject, handles);
In the other pushbutton, I will threshold the image.
And then in the other push button you can call the image by :
handles.output = hObject;
handles.bw = im2bw(handles.I);
imshow(handles.bw);
guidata(hObject, handles);

댓글 수: 1

hbanuqitah banuqitah
hbanuqitah banuqitah 2012년 12월 17일
can you please tell me tha sam thing if load image in axes and want other button to make operation to this image loaded by other pushbutton

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Image Analyst
Image Analyst 2012년 1월 10일

0 개 추천

Try this image processing GUI framework. It will get you up to speed quickly:
Description
This GUI will help the novice user get up to speed very quickly on using GUI-based applications. Everything is laid out in a very simple Step 1, Step 2, Step 3, etc. layout. It is a very good starting point for a typical image analysis application. This application uses GUIDE to do the user interface design, and has most of the basic controls such as buttons, listboxes, checkboxes, radio buttons, scrollbars, etc. It allows the user to select a folder of images, select one or more images and display them, to select a series of options, and to individually or batch process one or more images. The user can optionally apply a mask (region of interest) to the image so that only the area within the mask will be analyzed. The results are optionally sent to Excel. In this demo, I do some very basic particle sizing but in use, the user would replace that simple demo code in the function AnalyzeSingleImage() with their own code. Works with Windows or Unix since paths are all forward slashes. Requires the Image Processing Toolbox to do the simple particle sizing demo, but if you delete that demo code before using it, then the IP toolbox would not be required and it would still demonstrate the basic GUI-based file processing functionality.
Gaurav  Kaila
Gaurav Kaila 2012년 1월 10일

0 개 추천

Hey Chandra , Thanks for the help, I got it! Can you please help me out in another thing please, how do you create an array of HANDLES. i.e. if I have to get 6 (example) images to another callback, then what will the code be like. Should we use a for loop?? Thanks Again!
PS: Thanks Image Analyst!

댓글 수: 3

Chandra Kurniawan
Chandra Kurniawan 2012년 1월 10일
If I did not misunderstand,
what do you mean with 6 images?
Did you mean in 'Load Push Button' callback we have 6 different images?
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
Yes, i mean when i click the load push button , i should be able to load 6 images and transfer them to another function.
Chandra Kurniawan
Chandra Kurniawan 2012년 1월 11일
You can use uigetfile with 'multiselect' -> 'on'
And when reading the image, you can use for loop
Eq:
handles.output = hObject;
[fn pn] = uigetfile('*.jpg','select image','multiselect','on')
if ~isempty(fn)
for x = 1 length(fn)
handles.I{x} = imread(fullfile(pn,fn{x}));
end
end
guidata(hObject, handles);
In another pushbutton callback, you can call the image by the index
Eq:
handles.output = hObject;
handles.bw = im2bw(handles.I{1});
imshow(handles.bw);
guidata(hObject, handles);

댓글을 달려면 로그인하십시오.

Gaurav  Kaila
Gaurav Kaila 2012년 1월 10일

0 개 추천

And another thing, if i want to show a particular numerical result on the GUI , ill use the EDIT TEXT BOX. rite?? Can you help me in that too.
Thanks!

댓글 수: 13

Chandra Kurniawan
Chandra Kurniawan 2012년 1월 10일
Eq : I need to show mean value of the image
handles.output = hObject;
handles.Imean = mean(handles.I((:));
set(handles.edit1,'string',num2str(handles.Imean));
guidata(hObject, handles);
Note : you must have uicontrol named edit1 in your GUI
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
Okay, Thanks!
Also if i need to enter a value in the GUI which i have to use in the program, Ill use a EDIT TEXT BOX. and then how to proceed with it??
Sorry but im really very new at GUI.
Thanks!
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
And the above that you wrote should be written in the Edit Text Box Function or the Mean Evaluation Funtion.
Chandra Kurniawan
Chandra Kurniawan 2012년 1월 11일
You should place my code above in button callback (Mean Evaluation)
Image Analyst
Image Analyst 2012년 1월 11일
I don't recommend that since it's a measurement, not something you want the user to change. If you don't want the user to edit your value, I'd use a static text control instead, and use set() to assign a string to it.
text1String = sprintf('The mean = %.3f', meanValue);
set(handles.text1, 'String', text1String);
Again, there are nice demos and framework for this in MAGIC.
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
oh okay! Thanks Guys.
One last thing, if i need to input a value in a edit text box in a GUI and use that value in the function program.What should be my code??
Chandra Kurniawan
Chandra Kurniawan 2012년 1월 11일
a = str2double(get(handles.edit1,'string'));
now, you can pass 'a' in your function
Eq:
y = yourfunction(a)
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
This code is written in the edit text box callback or the mail function where the value is being used??
Chandra Kurniawan
Chandra Kurniawan 2012년 1월 11일
You should place it not in edit callback.
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
I am writing this code in the main function, and it says
??? Error while evaluating uicontrol Callback
??? Error using ==> KGUI>data_Callback
Too many output arguments.
Error in ==> KGUI>data_Callback at 382
n = data_Callback ((str2double(get(handles.n,'string'))));
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> KGUI at 44
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)KGUI('data_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
im writing it in the main function and it says too many output arguments. What to do??
Chandra Kurniawan
Chandra Kurniawan 2012년 1월 11일
What is 'data_Callback'?
Your function?
Can you show me about 'data_Callback'?
Gaurav  Kaila
Gaurav Kaila 2012년 1월 11일
I got it, Thanks a lot!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by