How can you intersect two white-foreground masks?
darker takes a per-pixel minimum. In two binary masks only a shared white pixel remains white.
Pixel experiment and interpretation
Require both sensors to confirm a point. With continuous confidence inputs the output is the lower score and still needs a decision rule.
from PIL import Image, ImageChops
def row(values):
return Image.frombytes('L', (len(values), 1), bytes(values))
list(ImageChops.darker(row([255,0,255]),row([255,255,0])).tobytes())Result [255, 0, 0]
中文
怎样提取两张二值前景图的交集?
darker 逐像素取较小值,两张黑白掩膜只有共同为白的位置能保留白色。
像素实验与适用边界
要求两个传感器都确认目标时取交集。若输入是连续置信值,输出是较低分数而非布尔结论。
from PIL import Image, ImageChops
def row(values):
return Image.frombytes('L', (len(values), 1), bytes(values))
list(ImageChops.darker(row([255,0,255]),row([255,255,0])).tobytes())结果 [255, 0, 0]