overlay op• 資料種類:image2d × mask → image2d
• 呼叫: 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')(要直接呼叫實作,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');從台帳取用則 opsannotate.get("annotate_invert"))
以反色填滿/描邊區域(region)。
這是在「不知道底色是亮還是暗,所以想用兩種情況下都看得見的顏色來畫」時的經典手法。省去了決定填色,代價是在中間調上會消失,所以
一定會在內部執行 annotate_invert_visibility 的量測。
★若底圖是單色(灰階),請先考慮有彩度的顏色。灰色沒有彩度,所以有彩度的顏色與任何灰階都能透過色相區分 —— 比反色更可靠,而且能一眼看出「這是疊加的線」(把角色色傳給 annotate_outline / overlay_mask)。反色真正發揮作用,是在底圖是彩色、選什麼顏色都可能衝突的時候。
另外,annotate_invert_visibility 量測的是 WCAG 的輝度比,所以無法評價「輝度相同但色相不同」這類可見性 —— 若用顏色來畫, 不要依賴這個 op 的數字。
mask : (H,W)
區域。布林值或 [0,1] 的權重。與影像形狀不同則拋出例外。
draw : {"fill", "margin"}
與 HALCON 的 set_draw 同一個詞。"fill" 連同內部一起反轉,"margin"
只反轉輪廓。輪廓是粗 width 像素(捨入為整數)的
帶,向區域內外各擴展一半。
width : float
draw="margin" 時帶的粗細(像素)。
mode : str
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"。
(H,W[,C]) float64
疊加了反轉的副本。不改寫輸入。
ValueError
形狀不一致 / 超出值域 / 未知的 draw mode on_invisible /
on_invisible="raise" 時不可見。
>>> 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
• dataset_conventions — 訓練資料集規範知識 —— COCO / YOLO / VOC 及外觀檢測中的陷阱
• 範例資料目錄(下載 URL / 授權) —— 2-D 用 skimage.data(BSD/公有領域)加合成圖,3-D 給出真實資料源(Stanford/PDS 等)的下載 URL。
• 運算子來歷與參考文獻 —— 該運算子族所依據的研究/方法出處。
• 演算法的正典(作者、年份)與用途見上面的族使用指南。
• annotate_paper_tour — py -3.11 examples/annotate_paper_tour.py
image2d 作為輸入)text_box · arrow · leader_line · label_points · crosshair · legend_box · color_bar · scale_bar
overlay)overlay_mask · overlay_labels · annotate_invert_visibility · annotate_invert_path
*Provenance: annotate.py — ANNOTATE 運算子登記表。本條目由 tools/opdocs.py md 自動產生(請勿手動編輯)。*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.