How to create an color sample from calculated LAB value?
이전 댓글 표시
From an created mask, I calculated the mean value of L, a and b channel. Now I would like to create an color sample (image) with this 'mean Lab value'.
This code does not work correct.
map = ones(60,60,3);
map = cast(map,'uint8');
map(:,:,1) = LMean*map(:,:,1);
map(:,:,2) = aMean*map(:,:,2);
map(:,:,3) = bMean*map(:,:,3);
figure('Name','Colour')
imshow(map);
Does anyone knows a solution?
댓글 수: 1
Walter Roberson
2013년 2월 28일
What range of values are LMean, aMean, bMean ?
채택된 답변
추가 답변 (1개)
Image Analyst
2013년 2월 28일
1 개 추천
You need to use imshow(map, []). The [] is important if you have floating point values outside the range of 0-1. But I have to tell you that viewing an LAB image as an RGB image makes little sense. The color you see will be renedered in RGB, with R being the lightness, green being the redness to greenness axis, and blue being the yellowness to blueness axis. The image will likely look like it's made of random colors.
You might want to use makecform('lab2srgb'.....) to create a "valid" (meaning it uses the "book formula" and is not colorimetrically accurate) RGB image.
댓글 수: 4
Walter Roberson
2013년 3월 1일
If the values of LMean etc are in the 0 to 1 range then because map() is initialized to uint8 one's, the result would be to round() the values to 0 or 1 exactly. The values would have to be in 0-11 or 0-127 or 0-240 or 0-255 to get something reasonable.
Martijn
2013년 3월 1일
Image Analyst
2013년 3월 1일
Probably.
Image Analyst
2013년 11월 1일
So, Martijn, are we done here, or not? If so, please officially "Accept" the answer. Thanks.
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!