I have a set of image data which is 256x256 matrix. I display the image data using the code below;
load topomatrix;
figure;
imshow(topomatrix,'displayrange',[]);
colormap('jet');
Now, I want to save the image with full display range and colormap, anyone know how to do it, is it using IMWRITE?
imwrite(topomatrix, 'topo.jpg');
Does anyone know how to do it, thank in advance!!!

 채택된 답변

Image Analyst
Image Analyst 2014년 11월 8일

0 개 추천

You'll need to scale it and convert it to an 8 bit RGB image.
image8Bit = uint8(255 * mat2gray(topomatrix));
jetMap = jet(256);
imshow(image8bit);
colormap(jetMap);
rgbImageToSave = ind2rgb(image8Bit, jetMap);
imwrite(rgbImageToSave, 'rgbImage.png'); % Save as PNG to avoid jpeg artifacts.

댓글 수: 4

TAY
TAY 2014년 11월 10일
Thank you for your help it works well. Thanks
TAY
TAY 2014년 11월 17일
hi, i have apply caxis to the colormap but when I save the image it still appear to be the same before I apply the caxis function, may I know how to solve this problem? Thank you.
Jane
Jane 2021년 10월 31일
What do we do if we have a 3d matrix instead?
Image Analyst
Image Analyst 2021년 10월 31일
If it has 3 planes/slices then you can use imwrite(). It will just consider it a color image. If you have more planes/slices, then either save each 2-D image separately or save the 3-D image into a .mat file.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Blue에 대해 자세히 알아보기

질문:

TAY
2014년 11월 8일

댓글:

2021년 10월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by