matlab 图像的保存
gcf:获取当前显示图像的句柄; 默认 plot 的 position 是 [232 246 560 420] 0. save >> A = randn(3, 4); >> B = 'hello world'; >> save 'data.mat' A B % 将多个对象保存进 data.mat 文件中 >> save data A B % 两个保存语句是等价的; 1. imwrite、saveas、print I = imread('./name.bmp'); % process the image matrix I % ... imwrite(I, './new_name.bmp'); imwrite 函数有两点需要注意的是: 保存的内容必须是 uint8 类型的, 无法很好地保存 gcf 对象 例如,我们需要对当前图像显示( imshow(I, []) )添加一些文本信息(使用 text(x, y, 'string') ),或者一些特殊形状标识(使用 rectangle('Position', [x, y, w, h], 'FaceColor', 'k') ), imwrite 是无法保存这些添加到 figure 之上的信息的,这时就需要使用 saveas() 方法,或者 print() 方法 saveas(gcf, './fig.tif'); print(gcf, '