initialising a color map
2 次查看(过去 30 天)
显示 更早的评论
How do I create a colormap with n*m pixels which is all white and then display it?
0 个评论
回答(2 个)
Image Analyst
2013-7-16
whiteColorMap = ones(256,3);
colormap(whiteColorMap);
colorbar;
Not sure what good that would be. What's the point?
2 个评论
Image Analyst
2013-7-16
No, that doesn't make sense. Colormaps are used as a pseudocolor look up table. For a typical uint8, 256 gray level image, use a 256 row by 3 column look up table. The row is the gray level, and the values in the row are the fraction of Red, Green, and Blue that that gray level will be displayed as. So it maps a gray level into a color. For example if you make a colormap
myColorMap = zeros(256,3); % All black
That will map all gray levels into black. Now if you set row 42 equal to a color
myColorMap(42, :) = [1, 0, 0]; % GL 42 maps to red
Then when you apply the colormap with the colormap() function, the look up table (myColorMap) says to make any/all pixels with gray level 42 show up as pure red instead of a gray with intensity 42. Does that explain it better? There are predefined colormaps you can use where you specify the number of levels, for example jet(256) or cool(256). Use fewer gray levels if you want a more "posterized" look.
Iain
2013-7-16
image_dat = uint16(randn(1024,1280)*5+5000); % random image (single colour channel)
imagesc(image_dat) % display it
colorbar % put the scale on the screen
colormap white % use the "white colormap"
custom_colormap = [r1 g1 b1;
r2 g2 b2
r3 g2 ...
...
rn gn bn];
r1, is the amount of red in the first colormap bin, g2 is the green in the second colormap bin, b3 is the blue in the 3rd colormap bin, (and so on) they are scaled from 0 (none) to 1 (max)
colormap(custom_colormap) % changes the display to the colormap you defined.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!