Color spaces

L*a*b color space

The Lab color space has 3 axis:

  • L = lightness: how bright is the pixel? (or color opponent: white vs. black)
  • a = color (opponent) information: red vs. green
  • b = color (opponent) information: blue vs. yellow

Heh? Wondering what does this mean? Here is an example!

Input image (RGB color coded):

And here are the Lab color channels. Note (!) how

  • red pixels have high values and green pixels have low values in the a-channel
  • blue pixels have high values and yellow pixels have low values in the b-channel
L a b

L channel:

a channel:

b channel:

You can easily transform a color image from RGB color space to Lab color space.

Mat testimg = imread("W:\\01_data\\07_testimgs\\person_detection\\9.png");
 
Mat LabImg;
cvtColor(testimg, LabImg, CV_RGB2Lab);
double minVal;
double maxVal;
 
vector<Mat> listLabChannels;
split(LabImg, listLabChannels);
 
minMaxIdx( listLabChannels.at(0), &minVal, &maxVal);
XLogger::Access()->Log( QString("L channel: min=%0 max=%1").arg(minVal).arg(maxVal) );
 
minMaxIdx( listLabChannels.at(1), &minVal, &maxVal);
XLogger::Access()->Log( QString("a channel: min=%0 max=%1").arg(minVal).arg(maxVal) );
 
minMaxIdx( listLabChannels.at(2), &minVal, &maxVal);
XLogger::Access()->Log( QString("b channel: min=%0 max=%1").arg(minVal).arg(maxVal) );
 
imwrite("W:\\tmp\\L.png", listLabChannels.at(0));
imwrite("W:\\tmp\\a.png", listLabChannels.at(1));
imwrite("W:\\tmp\\b.png", listLabChannels.at(2));

HSV color space

The HSV color space has 3 axis:

  • H = hue (color?)
  • S = saturation (how strong is the color?)
  • V = value (how bright is the pixel?)

Heh? Wondering what does this mean? Here is an example!

Input image (RGB color coded):

H S V
 
public/color_spaces.txt · Last modified: 2012/09/05 17:23 (external edit) · []
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki