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位
答案 0 :(得分:2)
如果我们修复它们会遇到一些问题。
由于warp
不接受'Parent'
属性,因此您需要确保您希望它出现的axes
是当前轴。您可以使用axes
函数强制执行此操作,并将轴句柄传递给它。
axes(hax_polar)
h = warp(x, y, z, I);
% Explicitly modify this axes
view(hax_polar, 2)
axis(hax_polar, 'square')
axis(hax_polar, 'tight')
axis(hax_polar, 'off')
调用imagesc
和plot
时,使用'Parent'
属性值对而不是将父级指定为第一个更清晰(并且跨系统更可靠)输入
imagesc(Ip, 'Parent', hax_polar);
plot(p(1:2:end), p(2:2:end), 'r+', 'Parent', hax_polar);
hold(hax_polar, 'off')
一旦我们解决了所有这些问题,我们就会得到一张看似正确的图像
clear all; close all; clc;
fp=figure();
hax_polar=axes('Parent', fp);
f_do_not_touch=figure('Name', 'Do not touch');
index=0;
I=imread('peppers.png');
while index < 7
[x, y, z]=makePolar(I);
axes(hax_polar)
h=warp(x, y, z, I);
% Different
view(hax_polar, 2);
axis(hax_polar, 'square')
axis(hax_polar, 'tight')
axis(hax_polar, 'off')
%
[Ip, alpha] = export_fig('test.png', '-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(Ip, 'Parent', hax_polar); hold on
plot(p(1:2:end),p(2:2:end),'r+', 'Parent', hax_polar)
hold(hax_polar, '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));