Ask Your Question
0

how do i access coordinates of a color in video ?

asked 2018-10-10 04:15:02 -0600

rohan__007 gravatar image

updated 2018-10-10 04:29:50 -0600

I want to know the coordinates of a given color in an image using OpenCV.

edit retag flag offensive close merge delete

Comments

try to explain that better, please. have a look at the faq

coordinates must be w.r.t screen.

did you mean the monitor screen ? that might not be possible at all.

berak gravatar imageberak ( 2018-10-10 04:28:00 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-10-10 04:50:06 -0600

holger gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-10-10 04:15:02 -0600

Seen: 620 times

Last updated: Oct 10 '18