save image with a long colormap
이전 댓글 표시
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.
답변 (1개)
Image Analyst
2015년 3월 7일
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));
카테고리
도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!