Wait for user to draw rectangle
2 次查看(过去 30 天)
显示 更早的评论
would like to crop an image using drawrectangle, the thing is I want the user to be the one who ends the selection process that's why I thought about using waitfor but it didn't work so far, can you explain why? here is my code
if true
function select_roi_Callback(hObject, eventdata, handles)
% hObject handle to select_roi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
guidata(hObject, handles);
A = handles.I;
h = drawrectangle(handles.axes1);
waitfor(h);
I = imcrop(A,h.Position);
imshow(I);
handles.I = I;
guidata(handles.figure1,handles);
h = datacursormode;
set(h,'DisplayStyle','datatip',...
'SnapToDataVertex','off','Enable','on')
end
thank you!
0 个评论
采纳的回答
Matt J
2018-11-1
编辑:Matt J
2018-11-1
If you use imrect instead, the code will pause until the user finalizes the rectangle selection by double-clicking.
h=imrect;
wait(h);
4 个评论
Carlos Castilla
2018-12-3
h1 = drawrectangle('Position', lPoints,'FixedAspectRatio',true);
while h1.Selected == 0
pause;
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!