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.