【发布时间】:2019-11-16 11:25:16
【问题描述】:
我有一些图像,我正在展示它们并在它们上面绘制线条,我如何在 Matlab 中将带有绘制线条的原始图像保存为 .mat 文件?
figure,imshow(geo.^0.25,[]);hold on;
plot(1:512,size(geo,1)-aa,'w','LineWidth',3);
【问题讨论】:
我有一些图像,我正在展示它们并在它们上面绘制线条,我如何在 Matlab 中将带有绘制线条的原始图像保存为 .mat 文件?
figure,imshow(geo.^0.25,[]);hold on;
plot(1:512,size(geo,1)-aa,'w','LineWidth',3);
【问题讨论】:
h = figure; %Keep the figure's handle in h
imshow(geo.^0.25,[], 'border', 'tight'); %Plot image without borders
hold on;
plot(1:512,size(geo,1)-aa,'w','LineWidth',3);
I = frame2im(getframe(h)); %Get the displayed "frame", and convert it to image.
save('I.mat', 'I'); %Save I (RGB matrix) to mat file.
【讨论】:
geo图片的格式是什么,是灰度还是RGB(彩色)?
geo.^0.25。
plot(有情节,你需要使用frame2im(getframe(h)),它的鲁棒性较差。见insertShape。
虽然输出是 fig 而不是 mat 文件,但您可能需要查看 matlab savefig 命令。它允许您保护图形并稍后在 MATLAB 中打开它们。
【讨论】: