generating CIELab Image

15 views (last 30 days)
Opiuz
Opiuz on 15 May 2012
Edited: KAE on 25 Jan 2019
I have set of color patches given by CIELab values.
How can I create image (preferably TIFF file) using only this data?
Again, image should show just these patches.
Thank you.

Answers (4)

KAE
KAE on 25 Jan 2019
Edited: KAE on 25 Jan 2019
Here is an example of how to write a tiff file containing 3 known Lab values. As a check, open the tiff file in Photoshop: the displayed image should have a stripe of cyan, orange, and green and the information tool will display Lab values at the cursor location which should be the same as what you used in Matlab. [If you are doing anything technical with these color values, you should feel uneasy that you don't need to specify the illuminant and observer: Matlab assumes they are D50/2 if I remember right.]
% Start with a matrix of zeros, and later substitute Lab values
nRow = 100;
nCol = 100;
Lab = zeros(nRow,nCol,3);
% Cyan stripe on top
iSlice = 1:33; % The rows of the image that we set to this Lab value
Lab(iSlice,:,1) = 63; % L
Lab(iSlice,:,2) = -90; % a
Lab(iSlice,:,3) = -15; % b
% Orange in middle
iSlice = 34:66;
Lab(iSlice,:,1) = 72; % L
Lab(iSlice,:,2) = 33; % a
Lab(iSlice,:,3) = 117; % b
% Green on bottom
iSlice = 67:100;
Lab(iSlice,:,1) = 81; % L
Lab(iSlice,:,2) = -59; % a
Lab(iSlice,:,3) = 84; % b
%%
lab_uint16=lab2uint16(Lab); % Convert to 16-bit
fileTif = 'test_Lab.tif'; % The tif file containing your Lab values
imwrite(lab_uint16,fileTif,'tif','ColorSpace','CIELab'); % 16-bit CIELAB

Walter Roberson
Walter Roberson on 15 May 2012
This is possible if you specify the ColorSpace parameter to imwrite() for a TIFF file. There is more detail in the imwrite documentation in the TIFF portion.
You could probably also use the new TIFF class to handle it.

Image Analyst
Image Analyst on 15 May 2012
Do you mean you want to convert those lab patches into RGB patches and then stitch them all together to form a rectangular RGB image? If so, you can use makecform() to convert lab values into "book formula" rgb values and then use regular assignment to put those rgb values into a 3D true color rectangular image array variable. You can then save it to a standard image format with imwrite() if you want to save it to disk.
If that's what you want and can't figure it out, write back. Needless to say, posting any kind of image or diagram might help explain what you want to do.
  1 Comment
Walter Roberson
Walter Roberson on 15 May 2012
TIFF files support cielab colorspace directly.
No word on whether browsers can display them....

Sign in to comment.


Opiuz
Opiuz on 16 May 2012
I am trying to avoid using RGB or any color space conversion, here is more why - I have physical color samples(1) and their L*a*b* values that gives me certain gamut. I'm trying to reproduce that gamut with printer (2), so I need to compare these two gamuts.
Since printer gamut is smaller I need to do mapping. For gamut mapping I need to have (1) in image form (required by software I'm using) so that later on I get mapped version - modified L*a*b* values(3) and finally I'm able to calculate deltaE of (1) and (3), which is my final goal.
  1 Comment
Walter Roberson
Walter Roberson on 16 May 2012
TIFF files with ColorSpace icelab do not have any colorspace conversion applied.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!