Skip to content

Color Spaces

Liam Lawrence edited this page Mar 27, 2017 · 5 revisions

You may have seen the term HSV appear in my code, this is a type of colorspace. The most common color space is RGB, or Red, Green, Blue. In OpenCV we swap the red and green channels and it is referred to as BGR. This is a very convenient way to display color as those are the three colors of pixels in our screens. The color space can be represented by something like this.

bgr

HSV is just another way to get the same information, however it is easier to pick out a shade of a specific color. HSV stands for Hue, Saturation, and Value, and the color space is more of a 3D space that looks like this.

hsv

  • Hue: 0 - 359° = color
  • Saturation: 0 - 100% = darkness
  • Value: 0 - 100% = whiteness

NOTE: OpenCV tries to save memory by making everything an 8-bit number, which is 0-255. This means that:

  • Hue: θ / 2 = H
  • Saturation: % * 255 = S
  • Value: % * 255 = V

LED Ring Color Choice

The most common color of LED Ring is generally a bright green. There are two main reasons for this choice.

  1. The other two main colors, Red and Blue, are heavily used throughout gamepieces and bumpers which would throw off your vision calculations.

  2. Cameras are meant to mimic the human eye, and there is a unique feature about our eyes that most people don't know. We actually have twice as many green receptors in our eyes compared to the red and blue. Almost all modern cameras use a Bayern filter, which has the same distribution of receptors in the camera as an eye. This feature in both cameras and humans allow us to distinguish more shades of green than any other color. This can be seen in the model below.

bayern

Due to this, you can tune your HSV values to pick out a very specific shade of green more easily than you could do with say blue or red.