-1

My Question: How can I recognize borders of each stone on the photo below? Size calculation will be an easy task.

First of all I have to tell you that I’m a new kid in image recognition, and I’ll be thankful for any:

  • propositions
  • useful links
  • book titles an chapters in it
  • algorithm
  • framework(especially C++)
  • etc.

So..

I have an image with small stones. And I have to measure their sizes(in pixels at firs).

enter image description here

I’ve already played with RGB values of any pixel, and highlighted pixels witch RGB values are between constants defined by me. I don't like that some stones are glued, and some borders are wider that it should be.

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;
        }

This is how my test app looks like at the moment:

enter image description here

PS: I know that my question is very vague, But I have to start and can't find or guess an appropriate direction. Any way, thanks for time you've already spent on it.

Matt
  • 2,554
  • 2
  • 24
  • 45
Nuzhdin Vladimir
  • 1,714
  • 18
  • 36

1 Answers1

2

You can't just play with RGB values to find the objects (superpixels). What you try to do is called watersheds segmentation. I recommend to use OpenCV library, they give an example similar to your case HERE .

Also, there are many algorithm implementations on github.

ChrisB
  • 498
  • 3
  • 10