保存malab imagsc()显示的图像

深度学习中有时候想查看网路中的某一蹭课的特征图,可以借用matlab 的imagesc()查看,但是用image()函数查看后,并不能用imwrite()函数保存,只能手动另存为,这样很麻烦,特别是遇到大批量操作的时候:
下面说说解决方案:
image()显示:

clear all;clc;close all;  
img = imread('feature_map_out_2_14.png');
I = rgb2gray(img);  
figure(1),imagesc(I);
colorbar,title('show by imagesc in figure2');axis off;

保存上面显示的图像:

clear all;clc;close all;  
img = imread('feature_map_out_2_14.png'); 
I = rgb2gray(img);  
filename = 'testmat.png';
imwrite( ind2rgb(im2uint8(mat2gray(I)), parula(256)), filename)

这样就可以保存了.

猜你喜欢

转载自blog.csdn.net/CV_YOU/article/details/85048066