- 2-Dimensional representation of the visible light spectrum
- Each pixel point corresponds to a different color which means that reflects different wavelengths of light
- Computer store images in RGB color space by default. What is RGB?
- Each pixel corrdinate (x,y) of a 2D plane contains 3 values ranging for intensities of 0 to 255 (8-bit).
- Red
- Green
- Blue
1-dimensional array
2-dimensional array
Think of it like an x y coordinate system.
3-dimensional array <- Where images are stored
Think of this as many two dimensional arrays stacked together.
RGB is an additive color model that generates colors by combining blue, green and red and different intensities/brightness.
OpenCV's default color space is RGB.
- Each colour appears in its primary spectral components of R, G and B
- A 3-D Cartesian co-ordinate system
- The Grayscale (Points of equal RGB values) extends from origin to farthest point
- Different colors are points on or inside the cube
- Images comprise 3 independent image plances (each for R,G,B respectively.)
- The number of bits representing each pixel in RGB space is called pixel depth
- Each R,G,B image is an 8-bit image
- Each RGB color pixel has a depth of 24 bits - full-color image.
- The total number of colors =
$(2^8)^3 = 16,777,216$
Note : OpenCV actually stores color in the BGR format.
Why? We use BRG order on computers due to how unsigned 32-bit integers are stored in memory, it still ends up being stored as RGB. The integer representing a color e.g. 0x00BBGGRR will be stored as 0xRRGGBB00.
Grayscale is a range of shades of gray without apparent color. The darkest possible shade is black, which is the total absence of transmitted or reflected light. The lightest possible shade is white, the total transmission or reflection of light at all visible wavelengths.
HSV (Hue, Saturation & Value/Brightness) is a color space that attempts to represent colors the way human perceive it. It stores color information in a cyclindrical representation of RGB color points.
- Hue - Color Value (0-179)
- Saturation - Vibrancy of Color (0-255)
- Value - Brightness or Intensity (0-255)
HSV is useful in computer vision for color segmentation. In RGB, filtering specific colors isn't easy. However, HSV makes it much easier to set color ranges to filter specific colors as we perceive them.
The Hue (Hue color range, goes from 0 to 179. NOT 360) and is mapped differently than standard in OpenCV.
Color Range Filters:
- Red - 165 to 15
- Green - 45 to 75
- Blue - 90 to 120
Why is the range of Hue 0-180° in OpenCV?
Now you understand why I said Hue is 0-179 in HSV space. 180 = 0.
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel, it was later supported by Willow Garage then Itseez. The library is cross-platform and free for use under the open-source BSD license.
You can use either C++ or Python with it.
- Python allows us to do to easily grasp complex concepts.
- Python is one of the easiest easiest languages for beginners
- It stores images in numpy arrays which allows us to do some very powerful operations quite easily
- Python is good for prototyping