Problem displaying 12 bit colormap, bug?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 2 Juin 2014
0 votes
Colormaps can be only 256 rows long, max.
2 commentaires
Nicole
le 2 Juin 2014
Sean de Wolski
le 2 Juin 2014
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')
Catégories
En savoir plus sur Blue dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!