フィルターのクリア

Using ROIPOLY in a GUI help!

3 ビュー (過去 30 日間)
Ellis Berry
Ellis Berry 2016 年 5 月 26 日
回答済み: Geoff Hayes 2016 年 5 月 29 日
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

回答 (1 件)

Geoff Hayes
Geoff Hayes 2016 年 5 月 29 日
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.

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by