Problem displaying 12 bit colormap, bug?

6 次查看(过去 30 天)
Hello,
I want to make a custom colour map to display my 12 bit images. The colour map I have created goes from:
dark red --> yellow --> white --> (black for only saturated pixels)
R = [linspace(0.25,1,512)'; ones(1535,1); 0];
G = [zeros(512,1); linspace(0,1, 512)'; ones((1023),1); 0];
B = [zeros(1024,1); linspace(0,1,1023)';0];
handles.myColourmap = [R G B];
snapshot = getsnapshot(handles.obj);
imshow(snapshot, [0 2^12-1], 'Parent', handles.axes2)
colormap(handles.myColourmap)
colorbar('NorthOutside')
The problem is that the colour map doesn't work at 12 bit, even though I have 12 bit images (they are stored in a 16-bit container). The problem manifests itself as every pixel value taking the first colour value from the colour map, and correspondingly, the colorbar displays only this colour for all values.
One way I can slightly solve this is to use an 8-bit colour map instead:
R = [linspace(0.25,1,64)'; ones(191,1);0];
G = [zeros(65,1); linspace(0,1, 64)'; ones((126),1);0];
B = [zeros(128,1); linspace(0,1,127)';0];
handles.myColourmap = [R G B];
This results in the colour map correctly displaying, almost. I assume it scales the colour mapping up from 8 bit to 12 bit, which means that when I wanted my saturated pixel (4095) to display black, I now have the last 15 or 16 pixel values displaying as black, which is not useful for my application at all.
I get the same problem when using a 12 bit colormap using one of the inbuilt functions, eg colormap(gray(4096)), displays every pixel as black, and sets every value in the colorbar to black.
There is nothing in the colormap help that says anything about how long the colour map can be, so why isn't it working, and how can I make it work?
Thank you in advance,
Nicole

采纳的回答

Titus Edelhofer
Titus Edelhofer 2014-6-2
Hi,
I'm not sure, if I understand correctly, but have you tried to display the image as an indexed image? Your 12 bit images, are they indexed? I.e., does your image has one channel (only) with values between 0 and 2047? In this case
imshow(snapshot, handles.myColourmap)
or, I'm not sure, maybe
imshow(snapshot+1, handles.myColourmap)
should work ...?
Titus
  1 个评论
Nicole
Nicole 2014-6-2
Yes it works!!! I'm not sure why it doesn't work calling the colormap function separately, but that will do me!
Thanks, Nicole

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2014-6-2
Colormaps can be only 256 rows long, max.
  2 个评论
Nicole
Nicole 2014-6-2
Ah! Thanks for that information. Shame it doesn't mention that in the colormap help; not that I can see at least.
Sean de Wolski
Sean de Wolski 2014-6-2
IA, that's only true for the 'Painters' renderer. OpenGL has no problem with it:
figure('Renderer','OpenGL')
surf(peaks);
colormap(jet(4096))
colorbar
set(gcf,'Renderer','painters')

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by