mask_ray
Description
mask_ray (written by A. Y. / JCU, May 1990) creates an ACRES-format 8-bit polygon mask from an ASCII vertex file using a 4-directional ray-casting parity test (casting rays left, right, up, and down from every candidate pixel to count boundary intersections).
CLI Options & Usage
mask_ray -infile <vertex_file> -outfile <acres_mask> -xlen <cols> -ylen <rows>
-infile <vertex_file>: ASCII file of(x, y)polygon vertices.-outfile <acres_mask>: Output ACRES-format 8-bit mask file (with 90-byte header;255inside,0outside).-xlen <cols> -ylen <rows>: Image width and height in pixels.
Algorithm
- Rasterizes all polygon edges onto the
xlen Γ ylenarray (value = 255) while tracking the polygonβs bounding box[xmin..xmax, ymin..ymax]. - For every non-boundary pixel
(i, j)inside the bounding box, casts four orthogonal rays (left,right,up,down) to the bounding box edges, counting transitions across the255boundary. If the crossing count is odd (count % 2 == 1), marks the pixel as interior (255). - Writes a 90-byte ACRES header (
header[3] = xlen,header[4] = ylen) followed by the mask array.