Using ROIPOLY in a GUI help!
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everybody,
I'm having a few issues using the roipoly function in a GUI. I want to use one pushbutton where you select the ROI and it saves the vertices of the polygon (xMin, yMin, xMax, yMax etc...) and I also want it to open in a separate figure to the GUI? My code so far makes it open in the gui screen which is ugly and doesn't save the xMin or xMax etc etc as variables :(!!! Here is my code at the moment:
% --- Executes on button press in pushbutton4. Choose Crop area
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
filename = uigetfile('*.*');
myimage = imread(filename);
[BW, xi, yi] = roipoly(myimage);
xMin = min(xi);
xMax = max(xi);
yMin = min(yi);
yMax = max(yi);
I want the vertices to be saved so that I can then use another pushbutton which calls them to use them! To do this do I use 'handles', if so, how?? Any help would be greatly appreciated.
Thanks,
Ellis
0 Commenti
Risposte (1)
Geoff Hayes
il 29 Mag 2016
Ellis - save the variables to the handles structure as
function pushbutton4_Callback(hObject, eventdata, handles)
filename = uigetfile('*.*');
myimage = imread(filename);
[BW, xi, yi] = roipoly(myimage);
handles.xMin = min(xi);
handles.xMax = max(xi);
handles.yMin = min(yi);
handles.yMax = max(yi);
guidata(hObject, handles);
In the above, we create new fields in the handles structure and then save that updated structure using guidata. Now, any other callback that fire (after this one) will have access to these four elements.
0 Commenti
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!