识别照片上每块石头的边界

时间:2017-08-28 19:50:15

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

我的问题:如何识别下方照片中每块石头的边框?尺寸计算将是一项简单的任务。

首先,我必须告诉你,我是一个新的图像识别小孩,我会感激任何:

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

所以..

我有一块小石头的图像。我必须测量它们的大小(以第一个像素为单位)。

enter image description here

我已经玩过任何像素的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;
        }

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

enter image description here

PS: 我知道我的问题很模糊,但我必须开始,找不到或猜测一个合适的方向。无论如何,谢谢你已经花了很多时间。

1 个答案:

答案 0 :(得分:2)

您无法使用RGB值来查找对象(超像素)。您尝试做的是称为分水岭分割。我建议使用OpenCV库,它们给出了一个与您的案例HERE类似的示例。

此外,github上有许多算法实现。