【发布时间】:2016-10-12 15:38:26
【问题描述】:
Warp 对象位于极坐标中,我无法使用axes 分配,因此我无法将表面对象直接传递给export_fig。
生成图像的代码但我无法为export_fig 捕获它,如下所示,因为它没有句柄
clear all; close all; clc;
img=imread('peppers.png');
% http://stackoverflow.com/a/7586650/54964
[h,w,~] = size(img);
s = min(h,w)/2;
[rho,theta] = meshgrid(linspace(0,s-1,s), linspace(0,2*pi,s));
[x,y] = pol2cart(theta, rho);
z = zeros(size(x));
figure;
h=warp(x, y, z, img);
view(2), axis square tight off
export_fig 接受图形和语法处理程序,但不接受表面图,因此我无法将 h 传递给函数
% https://github.com/altmany/export_fig
export_fig(figure_handle, filename);
export_fig(axes_handle, filename);
提案失败的示例代码
clear all; close all; clc;
fp=figure();
hax_polar=axes(fp);
f_do_not_touch=figure('Name', 'Do not touch');
index=0;
I=imread('peppers.png');
while index < 7
[x, y, z]=makePolar(I);
h=warp(x, y, z, I);
view(2), axis square tight off
%
[Ip, alpha] = export_fig('/home/masi/Images/masi', '-png', '-native', '-q101', '-a1', '-m1', '-RGB', '-nofontswap', '-transparent', '-dpng', ...
hax_polar);
p=FastPeakFind(Ip); % https://se.mathworks.com/matlabcentral/fileexchange/37388-fast-2d-peak-finder
imagesc(hax_polar, Ip); hold on
plot(hax_polar, p(1:2:end),p(2:2:end),'r+')
hold off
index=index+1;
end
function [x, y, z]=makePolar(img)
% http://stackoverflow.com/a/7586650/54964
[h,w,~] = size(img);
s = min(h,w)/2;
[rho,theta] = meshgrid(linspace(0,s-1,s), linspace(0,2*pi,s));
[x,y] = pol2cart(theta, rho);
z = zeros(size(x));
end
图。 1 输出图 Do not touch 获取内容并且主图由于隐式声明而中断
Matlab:2016a
操作系统:Debian 8.5 64 位
【问题讨论】:
-
请考虑添加minimal reproducible example。这意味着直接复制粘贴将运行代码。这很重要,因为您正在做非常具体的事情,我们不能只是猜测,我们可能会错过您的错误。
-
另外,
export_fig有什么关系?警告出现在surface -
图像生成很棒。
figure_handle和filename在您的代码中不存在,因此会出错。这就是我的意思。 -
这有关系吗?如果我这样做
figure_handle=figure; h=warp(x, y, z, img); view(2), axis square tight off; filename='whatevers.png' export_fig(figure_handle, filename);它也有效 -
使用
h_ax = get(h, 'Parent')获取包含曲面的轴的句柄,然后将h_ax传递给export_fig。
标签: matlab matlab-figure