How to delete previously made ROIs within a GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Image Analyst
2013년 8월 27일
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
Image Analyst
2013년 8월 27일
But you never set handles.mask1 equal to anything, at least nowhere that I could see. Same for mask2.
참고 항목
카테고리
Help Center 및 File Exchange에서 Author Block Masks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!