Lightness vs luma vs grayscale vs value

Alec Jacobson

May 17, 2013

weblog/

In image processing it's typical to convert an RGB input image into a more meaningful colorspace. For example it's often argued that distances in CIE L*a*b* colorspace are better correlated with perceived differences. Other times people simply use luma (aka luminance). I want to see how different these are. Here's a small MATLAB script to generate and compare different grayscale images:
im = imread('hans-hass.jpg');
imd = im2double(im);
% NTSC luminance == Matlab RGB2GRAY gray 
% [Levin et al 2004]
ntsc = rgb2ntsc(im);
% L*a*b*  lightness
% http://stackoverflow.com/a/6013156/148668
% ~[Lischinski et al 2006]
lab = im2double(applycform(im,makecform('srgb2lab')));
% HSV value
hsv = rgb2hsv(imd);
% simple rgb3gray
simple = imd(:,:,1)*0.3 + imd(:,:,2)*0.6 + imd(:,:,3)*0.1;
% Very naive rgb3gray
ignorant = sum(imd,3)/3;
% matrix of differences
row = [hsv(:,:,3) naive simple ntsc(:,:,1) lab(:,:,1)];
col = [hsv(:,:,3);naive;simple;ntsc(:,:,1);lab(:,:,1)];
diff = 0.5*kron(ones(5,1),row)+0.5*(1-kron(ones(1,5),col));
comp = [imd repmat(row,[1 1 3]);repmat([col diff],[1 1 3])];
imshow(comp);
This produces an array of comparisons: lightness comparison of grayscale images Some interesting things I noted were that the different implementations of luma are quite similar and they're all not so far from lightness. HSV value (the maximum of RGB) not surprisingly is very different.