Problem displaying 12 bit colormap, bug?

조회 수: 7 (최근 30일)
Nicole
Nicole 2014년 6월 2일
댓글: Sean de Wolski 2014년 6월 2일
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