【问题标题】:Recognize borders of each stone on the photo识别照片上每块石头的边界
【发布时间】:2018-02-06 03:49:16
【问题描述】:

我的问题:如何识别下图中每块石头的边界?尺寸计算将是一件容易的事。

首先我要告诉你,我是图像识别领域的新手,我会感谢任何人:

  • 命题
  • 有用的链接
  • 书名和章节
  • 算法
  • 框架(尤其是 C++)

所以..

我有一张带有小石头的图片。而且我必须测量它们的大小(以像素为单位)。

我已经玩过任何像素的 RGB 值,并且突出显示的像素和 RGB 值介于我定义的常量之间。我不喜欢有些石头是粘的,有些边框比它应该的宽。

for (y=0; y<height; y++,pixelIndex = width*y<<2)
    for (x=0; x<width; x++,pixelIndex+=4)
        if (pixelsData[pixelIndex  ]>self.minRedSlider.integerValue && pixelsData[pixelIndex  ]<self.maxRedSlider.integerValue &&
            pixelsData[pixelIndex+1]>self.minGreenSlider.integerValue && pixelsData[pixelIndex+1]<self.maxGreenSlider.integerValue &&
            pixelsData[pixelIndex+2]>self.minBlueSlider.integerValue && pixelsData[pixelIndex+2]<self.maxBlueSlider.integerValue) {
            resultData[pixelIndex] = 255;
            resultData[pixelIndex+1] = 255;
            resultData[pixelIndex+2] = 255;
        } else {
            resultData[pixelIndex] = 0;
            resultData[pixelIndex+1] = 0;
            resultData[pixelIndex+2] = 0;
        }

这是我的测试应用目前的样子:

PS: 我知道我的问题很模糊,但是我必须开始并且无法找到或猜测合适的方向。无论如何,感谢您花在这上面的时间。

【问题讨论】:

    标签: c++ image-processing image-recognition


    【解决方案1】:

    您不能只使用 RGB 值来查找对象(超像素)。您尝试做的事情称为分水岭分割。我建议使用 OpenCV 库,他们给出了一个类似于你的例子 HERE 的例子。

    另外,github上有很多算法实现。

    【讨论】:

    • 非常感谢!我会尽力让你知道结果。
    猜你喜欢
    • 1970-01-01
    • 2020-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-31
    • 2011-01-14
    相关资源
    最近更新 更多