如何提取洗衣机前面板的轮廓?

How to extract contour of the front panel the washing machine?

我正在寻找一种可靠的方法来提取洗衣机前面板的轮廓。或者只得到前面板的4个角点。 我试过颜色掩蔽但没有找到稳定的结果。 这里有一些例子:

三个可能的选择:

  1. 获取机器的一堆图像,手动确定一个标签说明门在哪里,然后训练一个卷积神经网络来回归每张图像的这些参数。

  2. 将每个图像视为一个单独的优化问题,其目标是估计最有可能对应于前面板的最佳矩形的参数。所以我们的模型是theta = (p_1, p_2, p_3, p_4),面板在图像中的四个2D位置。我们需要一个能量函数 E 来最小化 wrt theta(例如,使用带动量的梯度下降,或 RANSAC)。您可以使用许多术语,就像一些想法一样:

    一个。至少一些角应该是 "corner-like": 运行 一个简单的 corner detector,并定义一个能量 E_corner 来惩罚到最近角的距离。

    b。至少一些边缘(例如 p_1p_2p_3 之间)应该是 "edge-like":计算图像的梯度幅度 M = || \nabla I || 和使用能量 E_edge 强制沿着面板边缘 M 的值应该更大。例如,对于沿边的 x,y,让 E_edge(x,y)=1/(1+M(x,y))Robust losses 在这里往往更好)。

    c。使用每扇门实际上是投影的 3D 矩形这一事实:例如,请参阅 this question. An interesting idea is to start with a rectangle (representing the panel) and instead of regressing the p_i's, instead regress the parameters of an affine transform or even perspective projection transform (though this requires the algorithm estimate depth), that maps the starting rectangle to one in the image. You can then regularize 估计变换的参数,以防止输出不太可能的变换。

    d。使用矩形 内部 必须包含什么的知识。例如,给定四个角,您可以确定定义机器圆门的椭圆。该椭圆内的外观统计数据应该有些独特,门边界处的 edges/image 梯度也是如此;因此,您可以定义一个能量项,鼓励模型选择角,使得内部在白色背景上有一个深色椭圆形物体。

    总的来说,这种方法类似于 snakes, or active contour models, which might be worth looking into for you I think. However, energy-minimizing snakes tend not to consider the inside of the region they enclose; hence, some variant of the Mumford-Shah functional 可能是一个有用的补充(尽管 "door region" 的平滑度在您的情况下并不完全理想)。

  3. 如果您所有的机器都非常相似或几乎相同(就像您发布的那些一样),实际上可能最好 estimate a homography between the images. (See also here or here). Since the front of the machine is nearly planar, the fronts of different images must be related by a homography. Then knowing where the front panel is in one image will tell you where it is in all of them. For instance, check out the OpenCV tutorial for homographies,他们展示了如何撤消平面的透视变换允许您将一个图像透视变形到另一个图像(这里,一个投影的机器面板到另一个模板)。