initialising a color map
5 views (last 30 days)
Show older comments
How do I create a colormap with n*m pixels which is all white and then display it?
0 Comments
Answers (2)
Image Analyst
on 16 Jul 2013
whiteColorMap = ones(256,3);
colormap(whiteColorMap);
colorbar;
Not sure what good that would be. What's the point?
2 Comments
Image Analyst
on 16 Jul 2013
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
on 16 Jul 2013
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.
2 Comments
See Also
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!