Save a grayscale image as an colored image
Afficher commentaires plus anciens
I have a matrix
g
It is a grayscale image with size (32,32). I want it to save it as an colored image. How to do it?
imwrite(g, colormap(jet), 'test.png')
The above code gives some uniform random colored image and hence don't know what is the error in it.
Also,
imwrite(g, colormap(gray), 'test.png')
gives a completely white image. Can anyone tell me what is going wrong.
Réponse acceptée
Plus de réponses (1)
grayImage = imread('cameraman.tif');
subplot(2, 1, 1);
imshow(grayImage);
title('Original Gray Scale Image')
myColorMap = turbo(256);
rgbImage = ind2rgb(grayImage, myColorMap);
imwrite(rgbImage, fileName);
subplot(2, 1, 2);
imshow(rgbImage);
title('Image Converted to RGB with colormap and ind2rgb()')
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!

