save image with a long colormap

14 visualizzazioni (ultimi 30 giorni)
aa aa
aa aa il 7 Mar 2015
Risposto: Image Analyst il 7 Mar 2015
Hi all,
I'd like to know how to save an image in matlab with colormap. For example, when I write:
imwrite(Matrix,jet,'name.png')
The image is saved with the colormap jet. So far, so good. Now say I want a longer colormap, e.g.: [jet,flipud(jet),0 0 0]. When I type:
imwrite(Matrix,[jet,flipud(jet),0 0 0],'name.png')
It returns an error massage.
Note that when I type:
colormap([jet,flipud(jet),0 0 0])
The figure is displayed with the colormap [jet,flipud(jet),0 0 0], so there's nothing wrong with the colormap. I guess it's "imwrite" that makes the troubles.
Any ideas how to solve that?
Thanks in advance!
P.S. The matrix I want to save doesn't necessarily contain integers. Usually, its elements are of type float or double.

Risposte (1)

Image Analyst
Image Analyst il 7 Mar 2015
Color maps can only be 256 rows long. If you want more than that you'll have to use an RGB image, not an indexed one.
To remove a colormap from the displayed image, use a colormap of gray
colormap(gray(256));

Categorie

Scopri di più su Color and Styling in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by