One image input for multiple buttons and fields in a gui

I'm new to the forums and Matlab, so bear with me.
I'm working on a program where I upload a photo and have several buttons along the side that perform certain functions to that image (grayscale, resize etc.). My question is this:
Some of my functions require input from the user (blur, rotate etc.)
I've made fields for all the appropriate inputs. To upload the photo into my program, I've used the following code which is associated with a Browse button.
%Browse Button
function browse_Callback(hObject, eventdata, handles)
H.Id = imread((uigetfile('*.JPG')));
H.Ih = imshow(H.Id)
guidata(gcbf,H)
axes(handles.orig2)
imshow(H.Id)
This loads the image and copies it into another axes. That way, I can display the original image and the augmented image at the same time.
All this works so far, but here is where it gets tricky:
% --- Executes on button press in regblurbtn.
function regblurbtn_Callback(hObject, eventdata, handles)
a = get(handles.RADI,'String')
H=guidata(gcbf);
%sets up filter
blurfilt=fspecial('disk', a);
%applies filer to H
g=imfilter(H.Id, blurfilt, 'replicate');
imgshow(g);
Basically, I want to type a number in the field with the tag RADI. I want to upload the photo, have it displayed, type in a number in the RADI field and then click on the "Blur" button. I then want that number typed by the user to be passed in. It must perform this to the image stored in guidata. I believe my function for the image transform is correct, but trying to pass through the value is yielding a "Reference to non-existent field 'RADI'". Any help is appreciated. Also, if someone provides support, will it change for multiple inputs? Thank you!

 Accepted Answer

So why isn't the RADI field in the handles structure?
In your regblurbtn_Callback function, put this line to display what is in handles:
handles
Then push the button and look at the fields in the handles structure that print to the screen. Perhaps you simply misspelled the tag for the uicontrol.

More Answers (3)

Id and Ih come up as handles which represent the Imread and imshow of the uploaded photo.
I believe I've used your answer to another question for my program here, so I'm not 100% on how handles work.
Is that what goes under the
function RADI_Callback(hObject, eventdata, handles)
portion of the automatically generated gui code? Would I put
H.a = get(hObject,'String')
there and then use H.a back up in the regblurbtn?
OK, your answer helped me to figure out what I needed. Here's the updated code.
% --- Executes on button press in regblurbtn.
function regblurbtn_Callback(hObject, eventdata, handles)
H=guidata(gcbf);
handles
%sets up filter
blurfilt=fspecial('disk', H.Ir);
%applies filer to H
g=imfilter(H.Id, blurfilt, 'replicate');
imgshow(g);
and then for the field:
function RAD_Callback(hObject, eventdata, handles)
H.Ir=get(hObject,'String')
H.Ir
guidata(gcbf,H)
The problem I'm now having is that the program is expecting a double and it's getting a char for the line
blurfilt=fspecial('disk', H.Ir);
Thx for your help! Your advice was the catalyst for me to figure out what was going on. Problem solved.

Categories

Find more on Images in Help Center and File Exchange

Products

Asked:

on 8 May 2011

Community Treasure Hunt

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

Start Hunting!