From: Walter Roberson on
Nicola wrote:
> For instance, if I have got a vector describing a rectangle xy=[165 88;
> 401 88; 401 278; 165 278 on an image.
>
> Can i obtain the following vector [165 88;166 88; 167 88;...;400 88; 401
> 88; 401 89;...;401 277; 401 278;400 278;...;164 278;165 278;165
> 277;...;165 87 using a Matlab's inbuilt function or do I need to write
> it using FOR LOOPS? The algorithm must work for a generic vector with
> n-points and xy coordinates. Thanks!

"a generic vector" -- does that include vectors that might be at angles other
than horizontal and vertical?

If you restrict to horizontal and vertical, sub2ind and arrayfun should help.

Depending on exactly what you are trying to accomplish, roipoly() might be
beneficial.