pub fn normalize_polarity(image: &GrayImage) -> Cow<'_, GrayImage>Expand description
Return image as dark-text-on-light, inverting it when the background is
dark.
An already-correct image is returned borrowed and untouched, which is what
makes this safe to run on every input and idempotent: once the corners are
light a second call is a no-op. Both call sites rely on that — the page path
runs it before segmentation and MonOcr::preprocess runs it again per
crop, and the second call must not undo the first.