How to interrupt the roipoly function
4 ビュー (過去 30 日間)
古いコメントを表示
Good morning,
I am having problems with the roipoly function. I would like to know if it is possible to interrupt/cancel the action of roipoly.
I mean, I have a button (in a GUI) that launches the roipoly function but if I press the button unintentionally the antion starts and I can not cancel the action.
Is there any way to cancel the action without having to select the points in the image?
Thank you very much,
Silvia
0 件のコメント
回答 (1 件)
Image Analyst
2020 年 3 月 10 日
編集済み: Image Analyst
2020 年 3 月 10 日
If you put a title over your image that says to right click to cancel,
title('Left click vertices then right click to finish');
[x, y] = roipolyold();
then you can check if the returned point set is empty or less than 2, and if so, they bailed out.
if isempty(x) || length(x) <= 2
% Not a complete polygon. Better not continue with code or you'll get an error.
return;
end
You can also use questdlg() to ask the user if the polygon is acceptable or not, and if not, have them redraw it.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!