generating CIELab Image
9 views (last 30 days)
Show older comments
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.
0 Comments
Answers (4)
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
0 Comments
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.
0 Comments
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
on 15 May 2012
TIFF files support cielab colorspace directly.
No word on whether browsers can display them....
Opiuz
on 16 May 2012
1 Comment
Walter Roberson
on 16 May 2012
TIFF files with ColorSpace icelab do not have any colorspace conversion applied.
See Also
Categories
Find more on Modify Image Colors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!