annotate_invert — ANNOTATE overlay op

Data kinds: image2d × maskimage2d

Call: import fullseye as fs; fs.ledger.annotate_invert(img, mask, draw='fill', width=1.5, mode='complement', alpha=1.0, bits=128, min_contrast=1.5, on_invisible='warn') (to call the implementation directly, import annotate; annotate.annotate_invert(img, mask, draw='fill', width=1.5, mode='complement', alpha=1.0, bits=128, min_contrast=1.5, on_invisible='warn'); from the registry, opsannotate.get("annotate_invert"))

Usage

> This operator's description has not been translated yet. The original text follows as it is.

領域(region)を反転色で塗る/縁取る。

「地が明るいか暗いか判らないので、どちらでも見える色で描きたい」という

ときの古典手。塗り色を決めずに済むかわりに、中間調で消えるので

:func:annotate_invert_visibility の測定を内側で必ず通す。

地がモノクロ(グレー)なら、まず彩度のある色を検討すること。灰色には

彩度が無いので、彩度のある色はどの階調とも色相で区別がつく —— 反転色

より確実で、しかも「これは重ねた線だ」と一目で判る

(:func:annotate_outline / :func:overlay_mask に役割色を渡す)。

反転色が本領を発揮するのは、地がカラーでどの色を選んでも衝突しうるとき。

なお :func:annotate_invert_visibility が測るのは WCAG の輝度比なので、

「輝度は同じだが色相が違う」ような見え方は評価できない —— 色で描くなら、

この op の数字は当てにしないこと。

Parameters

----------

mask : (H,W)

領域。真偽か [0,1] の重み。画像と形が違えば例外

draw : {"fill", "margin"}

HALCON の `set_draw と同じ語。"fill" は中身ごと、"margin"`

輪郭だけを反転する。輪郭は太さ `width` 画素(整数に丸める)の

帯で、領域の内外へ半分ずつ広がる。

width : float

`draw="margin"` のときの帯の太さ(画素)。

mode : str

:data:INVERT_MODES。`"complement" は地の模様を残し、"xor"` は

模様を残したまま消えないことを保証し、`"contrast"` は白黒に倒して

見えることを保証する。

bits : int

`mode="xor" の bit マスク(1..255)。既定 0x80` は最上位 bit だけを

反転する ―― 必ず 128 階調跳ぶので消えない。`0xFF` にすると

`complement と同じ(崖ごと同じ)、0x0F` のような下位だけの

マスクはどの階調でも見えない(実測: 全 256 階調で比 1.5 未満)。

alpha : float

反転の効き。1.0 で完全に反転、0.5 なら地と反転色の中間

(**`mode="complement"` の 0.5 は必ず中間調になる** —— 反転色を

半分にすると消えるのは道理なので、警告はそれを拾う)。

min_contrast, on_invisible :

見えないと判ったときの扱い。`"warn"(既定)/ "raise"`(fail-closed)

/ `"ignore"`。

Returns

-------

(H,W[,C]) float64

反転を乗せた複製。入力は書き換えない

Raises

------

ValueError

形の不一致 / 値域外 / 未知の `draw mode on_invisible` /

`on_invisible="raise"` で不可視。

Examples

--------

>>> import numpy as np, annotate

>>> img = np.zeros((16, 16)); img[4:12, 4:12] = 1.0

>>> m = np.zeros((16, 16), bool); m[6:10, 6:10] = True

>>> out = annotate.annotate_invert(img, m)

>>> float(out[7, 7]), float(out[1, 1])

(0.0, 0.0)

>>> ring = annotate.annotate_invert(img, m, draw="margin", width=1)

>>> float(ring[7, 7]) # 中身は触らない

1.0

Detailed usage guide

figure_annotation family guide

Background guides (the physics and conventions behind this op)

dataset_conventions — 学習データセット規約の知識 — COCO / YOLO / VOC と外観検査での落とし穴

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_tourpy -3.11 examples/annotate_paper_tour.py

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

text_box · arrow · leader_line · label_points · crosshair · legend_box · color_bar · scale_bar

Same category (overlay)

overlay_mask · overlay_labels · annotate_invert_visibility · 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.