How to delete previously made ROIs within a GUI
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello all, I'm working on an image processing program, and I need to make a mask on an image using the imellipse and imrect within a GUI.
I would like to be able to choose either to mask the image with imellipse or with imrect. So I made the toggle buttons for each.
I would like to delete the previously created ROI shape, if I click the button of the other. I know you can delete ROIs with the delete(Roi_handle) command, but I cannot delete handle just like that because in GUIs we pass around the variables using the handles structure, and the error 'Root object may not be deleted' came up when I tried to delete the handle field of the ROI.
I'm quite inexperienced with structures and GUIs for your information. Below is the thing I tried to do but with no success whatsoever.
I really appreciate any ideas or help from you.
Fuad
% --- Executes on button press in ellipse_button.
function ellipse_button_Callback(hObject, eventdata, handles)
% hObject handle to ellipse_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of ellipse_button
s= get(hObject,'Value');
if s==1;
set(handles.none_button,'Value',0)
set(handles.rectangle_button,'Value',0)
oldMask= handles.mask2;
delete(oldMask)
mask=imellipse(handles.axes1);
handles.output2=wait(mask);
guidata(hObject,handles);
else
end
% --- Executes on button press in rectangle_button.
function rectangle_button_Callback(hObject, eventdata, handles)
% hObject handle to rectangle_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of rectangle_button
s= get(hObject,'Value');
if s==1;
set(handles.ellipse_button,'Value',0)
set(handles.none_button,'Value',0)
oldMask= handles.mask1;
delete(oldMask)
mask=imrect(handles.axes1);
handles.output2= wait(mask);
guidata(hObject,handles);
else
end
0 Commenti
Risposte (1)
Image Analyst
il 27 Ago 2013
Why have special buttons for deleting the masks? What is the purpose of handles.output2? Where do you ever assign handles.mask1 or handles.mask2?
2 Commenti
Image Analyst
il 27 Ago 2013
But you never set handles.mask1 equal to anything, at least nowhere that I could see. Same for mask2.
Vedere anche
Categorie
Scopri di più su Author Block Masks 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!