Azzera filtri
Azzera filtri

how to get handle of an image opened in the GUI figure window, to be used in other callbacks.

3 visualizzazioni (ultimi 30 giorni)
let an editbox named parmeter1,whose value is to be used for other callback functions, can be used in other callbacks by code
I am creating a gui where image is loaded in the gui figure window and is to be used in other callback functions like contrast adjustment. for this handle of the image is required. can anyone tell me the code for getting handle of an image file.
An answer with description would be better.
[SL: removed code formatting on the first line]

Risposte (2)

Fangjun Jiang
Fangjun Jiang il 19 Ott 2011
You must have an axes in your GUI. Let's say its tag is a. If you have an image shown in the axes, you can do this:
  2 Commenti
Fangjun Jiang
Fangjun Jiang il 19 Ott 2011
No, Walter! I think this is the use case. The OP has a GUI developed using GUIDE. The GUI has at least an axes and two push buttons. One button is to load an image to the axes. The other button is to do some processing on the image. To do the processing, the OP needs to get the handle of the image object. a is the tag of the axes so handles.a is the handle of the axes.
Follow your approach, it could work but should be:

Accedi per commentare.

Naz il 19 Ott 2011
handles.a=str2num(get(handles.parameter1,'string')); %similar to global variable (don't know for sure)
guidata(hObject, handles); %this must be written at the end of each function to make sure the changes to the hadles are saved.
I am not sure if you need to initialize handles.a during the GUI initialization. Try it directly first.
For the second question, (assuming that you use 'axis' to display the picture) I believe that you need to make them active:
Then, all operations on the axis will be performed on axis1. If you use the separate figure to display the image, then before operation you can make it active the following way:
figure(2); % activates new window for figure;


Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by