Convert to RGB file with colormap defined with different clim

6 vues (au cours des 30 derniers jours)
Fiona Gong
Fiona Gong le 26 Sep 2020
Commenté : Fiona Gong le 27 Sep 2020
Hi
I have a greyscale image 256x256 with background NaNs and all values are between [0 1]. I then use imshow to display the image, set Clim to different ranges [-0.1,1] or [-0.1 0.5] etc. Putting -1 in the clim range helps to set background NaNs to white. I then define colormap mannually with different clim ranges and save the cmap.
Once colormap and clim is finalised I then tried to save to rgb image using ind2rgb:
rgbImage = ind2rgb(greyImage, cmap);
imshow(rgbImage);
It gives me a different image and I think it's to do with Clim. Is there any way I can save greyscale image to rgb image using clim range and colormap I definied?
Many thanks!
Fiona

Réponse acceptée

Walter Roberson
Walter Roberson le 26 Sep 2020
There is a File Exchange contribution named freezeColors https://www.mathworks.com/matlabcentral/fileexchange/7943-freezecolors-unfreezecolors that takes a currently displayed colormap image and takes into account the active colormap and active clim, and converts the image into an RGB image. You can then fetch the CData property from the image handle.

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by