필터 지우기
필터 지우기

CIELAB values from TIFF image

조회 수: 10 (최근 30일)
Opiuz
Opiuz 2012년 5월 30일
댓글: Image Analyst 2022년 3월 12일
hello,
I'm trying to read CIELAB values from TIFF image in Matlab with:
A_lab= imread ('A', 'tiff');
what I get is A_lab<1x33x3 unit8> with values [0,255] which are not CIELAB values that I want (positive & negative integer and non-integer).
Have any idea?
thanks

채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 30일
편집: Walter Roberson 2018년 6월 8일
"If a file contains CIELAB color data, imread converts it to ICCLAB before bringing it into the MATLAB workspace because 8- or 16-bit TIFF CIELAB-encoded values use a mixture of signed and unsigned data types that cannot be represented as a single MATLAB array."
See http://www.mathworks.com/help/techdoc/ref/imwrite.html for a description of ICCLAB encoding

추가 답변 (4개)

Thomas
Thomas 2012년 5월 30일

KAE
KAE 2018년 6월 8일
편집: KAE 2018년 8월 14일
Here is what I used on a 16-bit CIELab TIFF file based on the 16-bit ICCLAB documentation here. Or there are conversions within encode_color.m which comes with the Image Processing toolbox, though some coefficients are different,
aUint16 = imread(fileData);
% Warning: Converting CIELab-encoded TIFF image to ICCLab encoding.
aDouble = double(aUint16); % Converting to double so can have decimals
Lab(:,:,1) = aDouble(:,:,1)*100/65280; % L
Lab(:,:,2) = aDouble(:,:,2)/256 - 32768; % a
Lab(:,:,3) = aDouble(:,:,3)/256 - 32768 ; % b
% Values are integers in the range [0, 65280]. L* values are multiplied by 65280/100.
% 32768 is added to both the a* and b* values,
% which are represented as integers in the range [0,65535].
  댓글 수: 2
KAE
KAE 2018년 8월 14일
편집: KAE 2018년 8월 14일
And substitute these 3 lines for 8-bit CIELab TIFF,
Lab(:,:,1) = aDouble(:,:,1)*100/65280; % L
Lab(:,:,2) = aDouble(:,:,2)/256 - 128; % a
Lab(:,:,3) = aDouble(:,:,3)/256 - 128 ; % b
By the way all these constants are powers of 2, for example 65280 = 2^16 - 2^8.
Roger Breton
Roger Breton 2022년 3월 11일
Thanks! Will experiment with this code...

댓글을 달려면 로그인하십시오.


John
John 2012년 5월 30일
IMREAD converts CIELAB to ICCLAB (it should also warn you that it is doing this). If you want the raw CIELAB values as stored in the TIFF, try the Tiff class instead.
  댓글 수: 5
KAE
KAE 2018년 8월 15일
I had trouble with trying to do this with the tiff class, possibly because the CIELab tiff files are a mix of signed and unsigned integers, and had to use imread instead.
% The a* and b* values seemed wrong with this approach
t = Tiff(fileScan, 'r');
aUint = read(t);
% This seemed to work better, though Matlab warns:
% "Converting CIELab-encoded TIFF image to ICCLab encoding"
aUint = imread(fileData);
Roger Breton
Roger Breton 2022년 3월 12일
편집: Walter Roberson 2022년 3월 12일
This code works for me :
aUint8 = imread('LabImage.tif')
aDouble = double(aUint8);
cielab(:,:,1) = aDouble(:,:,1) ./ (255/100);
cielab(:,:,2) = aDouble(:,:,2)-128;
cielab(:,:,3) = aDouble(:,:,3)-128;
The only 'problem', as noted by opiuz, is that, a* and b* lose their fractional values...

댓글을 달려면 로그인하십시오.


seackone
seackone 2018년 3월 26일
Hi, I want exactly the same! I've got a tiff file and looking for their lab values? Any ideas?
  댓글 수: 1
Image Analyst
Image Analyst 2022년 3월 12일
Try rgb2lab() for arbitrary "book" values. Those will not be the same as the true LAB values you'd get from measuring your sample on a spectrophotometer. If you need that, start a new discussion thread (it's complicated) after reading the attached tutorial.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by