Reads a binary mask image from disk and returns a logical vector
of length prod(img_dims) in column-major order, the format
the rest of the package expects. White / light pixels (above
threshold) become TRUE, dark pixels become FALSE. Use this
for image-based masks created with
webmorphR::mask_oval(),
painted in GIMP, drawn with PowerPoint shapes, or any other tool
that produces a binary PNG/JPEG.
Companion to make_face_mask() (parametric oval). Either
function returns the same logical-vector shape.
Arguments
- path
Path to a PNG or JPEG mask image.
- threshold
Numeric in
[0, 1]. Pixels with luminance above this becomeTRUE. Default0.5(mid-grey).- invert
If
TRUE, the mask is inverted (useful for black-on-white masks). DefaultFALSE.- expected_dims
Optional integer
c(nrow, ncol). When set, aborts if the loaded image's dimensions do not match. Useful for catching a wrong-resolution mask before it silently corrupts a downstream computation.