jb_mask_make
Description
jb_mask_make (written by A. Y. and J. E. H. C., May 1990, with JamesB parity-fill enhancements) generates an 8-bit OMG1 (JHC_header) filled polygon mask from an ASCII file of polygon vertex coordinates. It uses Bresenham-style integer edge stepping combined with scanline interior parity toggling to fill arbitrary closed polygons with a user-specified mask value (-val).
CLI Options & Usage
jb_mask_make -infile <vertex_file> -outfile <mask.8bit> [-val <0..255>]
-infile <vertex_file>: ASCII file listing(x, y)vertex coordinates around a closed polygon (currently defaults to512 Ã 512grid dimensions).-outfile <mask.8bit>: Output 8-bitOMG1(JHC_header) mask file (0outside,valinside).-val <0..255>: Digital Number assigned to pixels on and inside the polygon boundary (default:128).
Algorithm
- Boundary Rasterization: Reads consecutive
(x, y)vertex pairs from<vertex_file>, drawing each polygon edge onto thexlen à ylencanvas while distinguishing horizontal segments (value = 255) from non-horizontal crossing edges (value = 254) and accounting for local vertex extrema (peaks vs. monotonic crossings). - Scanline Parity Fill: Scans each row
j = 0 .. ylen-1from left to right, toggling aninboolean state (1= inside,0= outside) whenever a254edge crossing is encountered and assigningvalto all interior and boundary pixels. - Writes the resulting
OMG1header and 8-bit mask array for use withstencil.