线程的测试代码为什么这个带有 Colormap 的 imagesc-imshow 在 Matlab 中不起作用?它返回两个字段的结构,cdata
其中colormap
是cdata
图形的 RGB 表示
hFig=figure;
imagesc(time, potential, matrix); % choose any data
%% Test Code Starts
fr = getframe(hFig);
rgbImage = fr.cdata;
figure
imshow(rgbImage)
colormap parula
%% Test Code ends
saveas(hFig, '/home/masi/image.eps', 'eps');
输出
- 没有测试代码,
saveas
成功 - 使用测试代码,
saveas
以空白输出失败,您在屏幕上成功获得图形输出
预期输出:saveas
在磁盘上并在屏幕上显示对象的引用。我不明白由于引用imagesc
对象而引起的中断。
至export_fig
苏弗的提议。我确实成功地关注了这里
filenamePng=fullfile('/home/masi/image.png');
export_fig(filenamePng, '-png', hFig); % works with right resolution
export_fig(filenamePng, '-png', '-q101', hFig ); % works
export_fig(filenamePng, '-png', '-native', hFig); % works but reduced resolution i.e. your screen resolution of 72 dpi here
export_fig(filenamePng, '-png', '-q101', '-native', hFig); % works but reduced resolution
filename=fullfile('/home/masi/image');
% '-depsc' uses eps-3 so avoiding Matlab's buggy eps-2
% '-nocrop' for no cropping of the data
% '-a1' no anti-aliasing because we do not need it
export_fig(filename, '-png', '-eps', '-depsc', '-nocrop', '-q101', '-a1', hFig); % works
% results in 0.6 MB image
% '-opengl' results in 12 MB image and aliasing so incomplete vectorisation in Matlab
export_fig(filename, '-png', '-eps', '-depsc', '-nocrop', '-opengl', ...
'-q101', hFig); % works
% have -a1, much alias, 12 MB
% have -a4, much alias, 34 MB and warning `Warning: print2array generating a 33.2M pixel image. This could be slow and might also cause memory problems.`
所以不要-opengl
在Matlab中使用。另外,想想你是否可以在 Matlab 中可靠地使用 .eps。[苏弗,马西]
- 没有
-opengl
,渲染是否用 正确矢量化了-depsc
?文件的大小明显更小,没有明显的锯齿。TODO 测试自己。票在这里。
系统:Linux Ubuntu 16.04 64 位
硬件:Macbook Air 2013-mid
Linux 内核:4.6
Linux 内核选项:wl
Matlab:2016a