initialising a color map
조회 수: 3 (최근 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!