annotate_invert_visibility — ANNOTATE overlay op

• Data kinds: image2d × mask → table

• Call: import fullseye as fs; fs.ledger.annotate_invert_visibility(img, mask, mode='complement', alpha=1.0, bits=128) (to call the implementation directly, import annotate; annotate.annotate_invert_visibility(img, mask, mode='complement', alpha=1.0, bits=128); from the registry, opsannotate.get("annotate_invert_visibility"))

Usage

Measures, before drawing, whether the inverted color is actually visible on that background.

The advantage of inverted colour is that "you do not need to know the ground colour", but it has only 1 weakness, and a fatal one -- in mid-tones the inverse is the same colour. For 8bit grey, the complement of v=128 is v=127, and the WCAG contrast ratio is 1.014 (ratio 1.0 is "the same colour"; measured 2026-09-08). The band below ratio 1.5 spans v ∈ [113, 142], 30/256 levels = 12 % of all levels.

annotate_invert and annotate_invert_path call this internally and warn, but when you want fail-closed yourself, measure with this op before drawing (look at min_contrast, and if it is low, fall back to mode="contrast").

Parameters

img : (H,W) or (H,W,C)

Ground. Value range [0,1].

mask : (H,W)

Where the inversion goes. Boolean or weights in [0,1]. A different shape is an exception.

mode : str

One of INVERT_MODES.

alpha : float

Strength of the inversion. Pass the same value as when drawing -- visibility is determined not by "the inverted colour" but by

the colour actually placed, so lowering alpha changes the answer.

Returns

dict

pixels (number of pixels with weight >= 0.5) / min_contrast /

median_contrast / invisible_fraction (fraction whose ratio is below

INVERT_MIN_CONTRAST) / worst_xy (worst pixel,

None if none).

Examples

>>> import numpy as np, annotate

>>> flat = np.full((8, 8), 128 / 255.0) # mid-tone -- a ground where inversion vanishes

>>> rep = annotate.annotate_invert_visibility(flat, np.ones((8, 8), bool))

>>> round(rep["min_contrast"], 3)

1.014

>>> rep["invisible_fraction"]

1.0

>>> annotate.annotate_invert_visibility(flat, np.ones((8, 8), bool),

... mode="contrast")["min_contrast"] > 4.5

True

Detailed usage guide

• figure_annotation family guide

Background guides (the physics and conventions behind this op)

• dataset_conventions — Training-dataset conventions — COCO / YOLO / VOC and pitfalls in visual inspection

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

• The canonical algorithm (author, year) and its uses are named in the family usage guide above.

Runnable examples (verified samples that actually call this op)

• annotate_paper_tour — py -3.11 examples/annotate_paper_tour.py

Ops the type connects to (they accept table as input)

—

Same category (overlay)

overlay_mask · overlay_labels · annotate_invert · annotate_invert_path


*Provenance: annotate.py — ANNOTATE operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.