How to create an color sample from calculated LAB value?
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 28 Fév 2013
What range of values are LMean, aMean, bMean ?
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 28 Fév 2013
1 vote
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 commentaires
Walter Roberson
le 1 Mar 2013
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
le 1 Mar 2013
Image Analyst
le 1 Mar 2013
Probably.
Image Analyst
le 1 Nov 2013
So, Martijn, are we done here, or not? If so, please officially "Accept" the answer. Thanks.
Catégories
En savoir plus sur Color Segmentation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!