Wednesday, 11 July 2012

Convert RGB to L*a*b* (Lab Color space) in OpenCV

Problem 1: 
Using cvCvtColor convert a sRGB image into Lab image; In other words change the color space from RGB to LAB
Problem 2: 
Do the same in MATLAB and compare results

*********************************************************************************
Lets begin with problem 2


I_srgb=imread('C:\view0.png');
I_lab = applycform(I_srgb,makecform('srgb2lab', 'AdaptedWhitePoint', whitepoint('D65')));

Lets print some values from three channels (L , a , b)

I_lab(1,1:10,1)

ans =

  184  186  195  202  203  208  213  214  206  235

Trial>> I_lab(1,1:10,2)

ans =

  128  127  125  125  125  124  123  123  125  129

Trial>> I_lab(1,1:10,3)

ans =

  148  152  154  153  153  152  149  147  147  148

Now in OpenCV here is the program