I am not overly familiar with image processing. I know a little about it from University, but I have not really done any for a while and I have found myself with a problem that requires it.

What I have is frames of a video which may or may not have blocks (usually 16x16) of solid colour (either purple or green) randomly distributed throughout. What I would like to be able to do is pick out each block of colour and count up the pixels in each.

I have looked into things, and I realise I could perform some sort of edge detection which would produce an image with just the edges highlighted, but that seems to only produce the further problem of how to then identify the blocks from their edges.

I am hoping somebody can point me in the right direction for how to solve this problem, because so far my research has been rather fruitless. There doesn't seem to be a whole lot of useful material out there for a beginner such as myself.

I am using C++, though I would prefer to avoid using external libraries if possible. I am prepared to develop my own implementations.

  • 1
    $\begingroup$ I don't have much image processing experience, but perhaps look at the gradient (change in color between pixels). If it's a block of solid color, the gradient should be zero throughout the interior of the block. $\endgroup$ – David K Sep 15 '14 at 12:48
  • 2
    $\begingroup$ Wouldn't it be easier to just scan the images looking for pixels that are purple or green. When you find them, recursively look at their neighbors, looking for more purple or green. Accumulate the width, height and number of pixels in the block as you go. $\endgroup$ – Simon B Sep 15 '14 at 14:27
  • $\begingroup$ @SimonB You're right. As usual I have been overthinking it. :P Only a small modification to my existing code is necessary to do that and it should be sufficient for my purposes. Thanks! $\endgroup$ – Luke Sep 15 '14 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.