Getting average LAB color from a 16 bit TIFF LAB file
Posted: 2012-06-28T20:56:11-07:00
I have a 16 bit TIFF LAB file.
QUESTION 1 - Is this the best way for me to find out the average color in LAB colorspace? Since the initial TIFF is already in LAB colorspace, I want to use a method that just averages the colors in LAB -- without jumping through RGB at all. I want to avoid any type of calculations with colorspace conversions.
QUESTION 2 - Using this method, I'm getting "0.150942/0.496986/0.537743", when Photoshop comes up with a LAB average of L:15 a:8 b:0. It's looking to me like rgb.red() * 100 will give me L, but I'm not sure how to get a and b. I read at "http://www.imagemagick.org/Usage/color_basics/" that red() stores L, green() stores a, and blue() stores b.
QUESTION 3 - In Photoshop, I've only seen integer values for RGB or LAB. Are decimal values for LAB permissible, and I've just been seeing rounded values in Photoshop?
QUESTION 1 - Is this the best way for me to find out the average color in LAB colorspace? Since the initial TIFF is already in LAB colorspace, I want to use a method that just averages the colors in LAB -- without jumping through RGB at all. I want to avoid any type of calculations with colorspace conversions.
Code: Select all
// library already initialized, image already loaded from a file
image.colorSpace(LABColorspace); // I guess this might be detected automatically and not needed, once I actually have a 16 bit TIFF LAB file... Right now I only have an 8 bit TIFF RGB file, but that's another post...
image.scale(Geometry(1, 1));
ColorRGB rgb(croppedImage.pixelColor(0, 0));
cout << rgb.red() << rgb.green() << rgb.blue() << endl;
QUESTION 3 - In Photoshop, I've only seen integer values for RGB or LAB. Are decimal values for LAB permissible, and I've just been seeing rounded values in Photoshop?