Skip to contents

Reads an image, converts to grayscale, and thresholds to a logical mask. White-on-black masks (the typical convention) become TRUE inside the face region and FALSE outside.

Usage

load_face_mask(path, threshold = 0.5, invert = FALSE)

Arguments

path

Path to a PNG or JPEG file. Reading PNG requires the png package; reading JPEG requires jpeg (both Suggests).

threshold

Numeric in [0, 1]. Pixels with grayscale value strictly greater than this are TRUE. Default 0.5.

invert

If TRUE, the mask is inverted (useful for black-on-white masks). Default FALSE.

Value

Logical vector of length prod(img_dims), column-major (the convention face_mask() also uses).

Details

Use this when you have a hand-crafted or anatomically tuned mask and want to feed it to diagnose_infoval() or infoval() via the mask argument. For the standard Schmitz 2024 oval, face_mask() is faster and adds no dependencies.