Counting polygon vertices while polygon is drawn

3 ビュー (過去 30 日間)
Susan
Susan 2013 年 4 月 10 日
Is there a way to count the number of polygon vertices specified in impoly(), roipoly(), or roipolyold() while the polygon is being drawn? I'd like to add a counter to my GUI to let the user know how many points they've selected while drawing a polygon. This way, they can make sure to have the minimum number of points required for each polygon so that the program performs optimally. Thus far,I have only been able to accomplish creating such a counter using ginput and a while loop. However, I really don't like that ginput cannot be constrained to an axes object. I'd prefer to limit my user from clicking outside the desired area (i.e. the image). Anyhow, I would greatly appreciate any suggestions/comments. Thanks!

回答 (1 件)

Image Analyst
Image Analyst 2013 年 4 月 10 日
Not that I know of. You could put something like imline() in a loop and build it up just one line at a time. But how many vertices are required? If there are just a few (4-8), why not just count them when they're all done and alert them only then if there are not enough?
  1 件のコメント
Susan
Susan 2013 年 4 月 10 日
The required number of vertices is 15 per polygon. And there may be anywhere from 1-3 polygons drawn per image. I like how ginput() returns what button was pressed so that you can have it in a while loop and end the selection when the right mouse button is pressed. I really wish that imline did that. If so, it would be perfect. Thanks for the suggestion.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by