Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hmm well - i am pretty sure this is not what you want but let me answer your question like it was asked. Find the coordinates for a specific colour in images.

First of all a video consists of several frames(a frame is an image). So lets just see how to do it for images.

Well we know that an image consists of pixels. A non grayscale image will have 3 channels(Red, Green, Blue) - the order of the channels after you read in the picture depends on the library you use. Some libs use (RGB), for opencv its (BGR). The channels consists of columns(sum(amount of columns) = total width of image) and rows (sum(amount of rows) = total height of image) Each Channel will have pixels in range from 0 - 255 - this means 256 values. So assuming you have the colour values you need to find in format (BGR)

  • Iterate the 3 channels
  • Keep an counter for the column and row
  • Find the correct combination for the given colour
  • Save the column and row coordinates - these are already the x, y coordinates for a pixel of a specific colour.

I am pretty sure just getting the x,y coordinates for pixels of a specific colour is not enough. Maybe you want to detect areas of colours and their coordinates. Maybe you want to detect "colours" in a common sense. This mean for example "Red" as light red, dark red. In that case you need a range.

I am a bit confused but maybe you can make yourself clear a bit more what you really want to do. "coordinates of colours" is really very generic.

Greetings, Holger

P.S Any comment / hints on my explanation is welcome - maybe i have some thinking errors.