How to create an color sample from calculated LAB value?
Mostrar comentarios más antiguos
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 comentario
Walter Roberson
el 28 de Feb. de 2013
What range of values are LMean, aMean, bMean ?
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 28 de Feb. de 2013
1 voto
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 comentarios
Walter Roberson
el 1 de Mzo. de 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
el 1 de Mzo. de 2013
Image Analyst
el 1 de Mzo. de 2013
Probably.
Image Analyst
el 1 de Nov. de 2013
So, Martijn, are we done here, or not? If so, please officially "Accept" the answer. Thanks.
Categorías
Más información sobre Color Segmentation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!