通过背景彩色图像分割 - OpenCV的机器人 [英] Image segmentation by background color - OpenCV Android

查看:766
本文介绍了通过背景彩色图像分割 - OpenCV的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图段名片,分裂他们用背景色来对待他们的利益不同的区域。

I'm trying to segment business cards and split them by background color to treat them as different regions of interest.

例如这样的一张牌:

For example a card of this sort:

应该能够被分割成两个图像,因为有2的背景色。是否有关于如何解决这个有什么建议?我试着做一些轮廓分析,并没有变成太成功。

should be able to be to be split into two images as there are 2 background colors. Are there any suggestions on how to tackle this? I've tried doing some contour analysis which didn't turn out too successful.

其他的例如卡:

Other example cards:

这卡应该给3分割,因为有三个部分,尽管它只有2种颜色(尽管2色会好起来的)。

This card should give 3 segmentations, as there are three portions even though it's only 2 colors (though 2 colors will be okay).

以上卡应举一个分割,因为它只是一个背景颜色。

The above card should give just one segmentation as it is just one background color.

我不是想渐变背景,只是还没有。

I'm not trying to think of gradient backgrounds just yet.

推荐答案

这取决于其他卡怎么看,但图像都是在伟大的品质,它不应该是太辛苦了。

It depends on how the other cards look, but the images all are in that great quality, it should not be too hard.

在您发布的例子,你可以只收集边界像素(最左边的列,最右列,第一行,最后一行)的颜色,并把你的发现地的背景颜色。或许,检查是否有足够的像素rougly相同的颜色。你需要某种距离测量。一个简单的解决方法就是用欧拉距离RGB色彩空间。

In the example you posted, you could just collect the colors of the border pixels (most left column, most right column, first row, last row) and treat what you find as possible background colors. Perhaps check if there are enough pixels with rougly the same color. You need some kind of distance measuring. One easy solution is to just use the eulerian distance in RGB color space.

一个更通用的解决办法是找到集群的整体形象和威胁,每一种颜色(再次公差)具有超过总像素数量作为背景色的x%的颜色直方图。但是你定义的背景是什么取决于你想要达到和你的图片是如何LOOL什么。

A more generic solution would be to find clusters in the color histograms of the whole image and threat every color (again with tolerance) that has more than x% of the overall pixel amount as a background color. But what you define as background depends on what you want to achieve and how your images lool.

如果您需要进一步的建议,你可以发布更多的图像和标记你想被检测为背景色的图像部分,哪些parst没有。

If you need further suggestions, you could post more images and tag what parts of the images you want to be detected as a background color and what parst not.

-

编辑:您的两个新的图像也显示了同样的模式。背景颜色占据了形象的重要组成部分,没有噪音,也没有颜色渐变。因此,一个简单的方法可能如下所示:

Your two new images also show the same pattern. Background colors occupy a big part of the image, there is no noise and there are no color gradients. So a simple approach could look like the following:

  • 计算图像的直方图:看<一href="http://docs.opencv.org/modules/imgproc/doc/histograms.html#calchist">http://docs.opencv.org/modules/imgproc/doc/histograms.html#calchist和<一href="http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.html">http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.html

查找最突出颜色的柱状图。如果你不希望自己遍历垫可以使用minMaxLoc(<一href="http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#minmaxloc">http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#minmaxloc)如图所示calchist文档中(见上文),以及如果颜色占据了像素数的足够百分比保存它,并设置根据仓在直方图为零。重复操作直到完成比例没有达到了。然后,将有保存最突出的颜色列表,你的背景颜色。

Find the most prominent colors in the histogram. If you do not want to iterate over the Mat yourself you can use minMaxLoc ( http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#minmaxloc) as shown in the calchist documentation (see above), and if the color takes up enough percentage of the pixel count save it and set the according bin in the histogram to zero. Repeat until your percentage is not reached any more. You will then have saved a list of the most prominent colors, your background colors.

阈值不同背景颜色,你有图像。参见:<一href="http://docs.opencv.org/doc/tutorials/imgproc/threshold/threshold.html">http://docs.opencv.org/doc/tutorials/imgproc/threshold/threshold.html

Threshold the image for every background color you have. See: http://docs.opencv.org/doc/tutorials/imgproc/threshold/threshold.html

在生成的threadholded图像找到相应区域的每一个背景色。参见:<一href="http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html">http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html

On the resulting threadholded images find the corresponding region to every background color. See: http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html

如果你有例子,不使用这种方法的工作,只是张贴他们。

If you have examples that do not work with this approach, just post them.

这篇关于通过背景彩色图像分割 - OpenCV的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆