gpt4 book ai didi

c# - 两个图像之间的差异

转载 作者:太空宇宙 更新时间:2023-11-03 21:22:39 24 4
gpt4 key购买 nike

使用 this图像作为引用我想找到 this 底部的脏点图片。

我能够将第二张图像调整为相同的比例和方向,现在尝试使用 absdiff 找到该点但由于图像并不完全匹配,所以我在 diff image 上有优势.

我在想,我需要在 n x n 像素这样的区域中找到最小差异,而不是具有相同坐标的像素之间的差异。所以问题是:OpenCV 是否有一些内置的东西和/或是否有更好的解决方案?

编辑:使用 threshold 的解决方案和 erode :

public static Image<Bgr, Byte> Diff(Image<Bgr, Byte> image1,
Image<Bgr, byte> image2,
int erodeIterations=2)
{
return Diff(image1, image2, new Bgr(50, 50, 50), erodeIterations);
}

public static Image<Bgr, Byte> Diff(Image<Bgr, Byte> image1,
Image<Bgr, byte> image2,
Bgr thresholdColor,
int erodeIterations)
{

var diff = image1.AbsDiff(image2);
diff = diff.ThresholdToZero(thresholdColor);
diff = diff.Erode(erodeIterations);
return diff;
}

最佳答案

不确定 OpenCV,但解决这个问题应该不难。对齐两个图像并找到差异图像,就像您已经完成的那样。在差异图像上使用 NxN 滑动窗口,并计算窗口内明显不同的像素数,即忽略最多 10 个灰度级的差异。在整个图像上找到这些总和的最大值,这应该会突出显示您需要的内容。

关于c# - 两个图像之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16607031/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com