Warp object is in polar coordinates which I cannot assign with axes
so I cannot pass the surface object directly to export_fig
.
Code which generates the image but I cannot catch it for export_fig
as shown below because no handle for it
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
The export_fig
accepts the figure and syntax handlers but not the surface map so I cannot pass h
to the function
% https://github.com/altmany/export_fig
export_fig(figure_handle, filename);
export_fig(axes_handle, filename);
Example code which fails with proposals
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
Fig. 1 Output where the figure Do not touch
gets content and the main figure breaks because implicit declarations
Matlab: 2016a
OS: Debian 8.5 64 bit
See Question&Answers more detail:
os