필터 지우기
필터 지우기

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