##
POLYFILLV

The
POLYFILLV function returns a vector containing the one-dimensional subscripts of the array elements contained inside a
polygon defined by vectors *
X*
and *
Y*
.

If no points are contained within the polygon, a -1 is returned and an informational message is printed. The *
X*
and *
Y*
parameters are vectors that contain the subscripts of the vertices that define the polygon in the coordinate system of the two-dimensional *
S*
_{
x}
by *
S*
_{
y}
array. The *
S*
_{
x}
and *
S*
_{
y}
parameters define the number of columns and rows in the array enclosing the polygon. At least three points must be specified, and all points should lie within the limits: 0 *
£*
X*
i*
< S*
x*
and 0 *
£*
Y_{
i}
< S*
y*
*
"*
*
i*
.

As with the POLYFILL procedure, the polygon is defined by connecting each point with its successor and the last point with the first. This function is useful for defining, analyzing, and displaying regions of interest within a two-dimensional array.

The scan line coordinate system defined by Rogers in *
Procedural Elements for Computer Graphics*
, McGraw-Hill, 1985, page 71, is used. In this system, the scan lines are considered to pass through the center of each row of pixels. Pixels are activated if the center of the pixel is to the right of the intersection of the scan line and the polygon edge within the interval.

###
Calling Sequence

Result = POLYFILLV(*
X, Y, S*
_{
x}
*
, S*
_{
y}
*
[, Run_Length]*
)

###
Arguments

####
X

A vector containing the X subscripts of the vertices that define the polygon.

####
Y

A vector containing the Y subscripts of the vertices that define the polygon.

####
S_{
x}

The number of columns in the array surrounding the polygon.

####
S_{
y}

The number of rows in the array surrounding the polygon.

####
Run_Length

Set this optional parameter to a nonzero value to make POLYFILLV return a vector of run lengths, rather than subscripts. For large polygons, a considerable savings in space results. When
run-length encoded, each element with an even subscript result contains the length of the run, and the following element contains the starting index of the run.

###
Example

To determine the mean and standard deviation of the elements within a triangular region defined by the vertices at pixel coordinates (100, 100), (200, 300), and (300, 100), inside a 512 x 512 array called DATA, enter the commands:

P = DATA(POLYFILLV([100,200,300], [100,300,100], 512, 512))

STD = STDEV(P,MEAN)