Computer Vision Library
Files | Functions
Color-Space Conversions

Files

file  colors.js
 Different color-space conversions.
 

Functions

void ycbcr2rgb ()
 
void rgb2grey ()
 
void rgb2ycbcr ()
 

Detailed Description

This group provides different GPU based color space conversion algorithms. The color conversions are done using OpenGL (WebGL) shaders for fast GPU transformations

Function Documentation

◆ rgb2grey()

void rgb2grey ( )

RGB to Grayscale color space tranform

Overview
This method implements RGB to gray transformation using Y (lume) compoenent from YCbCr color-space.
Example image result
rgb2gray_ex.jpg
RGB to Gray-scale image transform
External resources
See also
rgb2ycbcr

◆ rgb2ycbcr()

void rgb2ycbcr ( )

RGB to YCbCr color space tranform

Overview
This method implements RGB to YCbCr transformation using the math equation below. The expected input is in range [0 – 255] or in [0.0 - 1.0] for OpenGL GLSL shader. The output values are in range [16 – 235] for Y and [16 – 240] for Cb and Cr color components.
Math theory
\(\displaystyle{\left[\begin{matrix}{Y}\\{C}{b}\\{C}{r}\end{matrix}\right]}={\left[\begin{matrix}{0.0625}\\{0.5}\\{0.5}\end{matrix}\right]}+{\left[\begin{matrix}{0.257}&{0.504}&{0.098}\\-{0.148}&-{0.291}&{0.439}\\{0.439}&-{0.368}&-{0.071}\end{matrix}\right]}{\left[\begin{matrix}{R}\\{G}\\{B}\end{matrix}\right]}\)
Example image result
rgb2ycbcr_ex.jpg
RGB to YCbCr image transform
External resources
See also
rgb2grey ycbcr2rgb

◆ ycbcr2rgb()

void ycbcr2rgb ( )

YCbCr to RGB color space tranform

Overview
This method implements YCbCr to RGB transformation using the math equation below. The output values are in range [0 – 255] for Y and [16 – 240] for Cb and Cr color components.
Math theory
\(\displaystyle{\left[\begin{matrix}{R}\\{G}\\{B}\end{matrix}\right]}={\left[\begin{matrix}{1.164}&{0.000}&{1.596}\\{1.164}&-{0.392}&-{0.813}\\{1.164}&{2.017}&{0.000}\end{matrix}\right]}-{\left[\begin{matrix}{0.0625}\\{0.5}\\{0.5}\end{matrix}\right]}{\left[\begin{matrix}{Y}\\{C}{b}\\{C}{r}\end{matrix}\right]}\)
External resources
See also
rgb2ycbcr