Code which yields a gap at the line from origo (0,0) to (1,0), which seems to reach zero if C
dimensions reaches infinity; however, I cannot get it small enough with any sizes of C
so I think the artifact can be caused by Matlab figure internal features or image data itself (AnderBiguri) because it does not seem to occur for img=imread('peppers.png')
.
Code which makes the image, stores it by export_fig
and maps it from Cartesian to Polar where the artifact occurs
close all; clear all; clc;
%% Make image
f1=figure;
hax=axes(f1);
x = rand(1,6);
y = exp(rand(1,181));
C = rand(3613,3613);
imagesc(hax, x, y, C);
box(hax, 'off');
axis(hax, 'off');
set(hax, 'yTickLabel', []);
set(hax, 'xTickLabel', []); % for polar presentation
set(hax, 'Ticklength', [0 0]); % http://stackoverflow.com/a/15529630/54964
filename='/home/masi/Images/testi';
% by default, export_fig has cropping
[img, alpha] = export_fig(filename, '-png', '-native', '-q101', '-a1', '-m1', '-RGB', '-nofontswap', '-dpng', hax);
close all;
%% Read Image
img=imread('/home/masi/Images/testi.png');
% http://stackoverflow.com/a/7586650/54964
[h,w,~] = size(img);
s = min(h,w)/2; % have here .../1, some phenomenon occurs
[rho,theta] = meshgrid(linspace(0,s-1,s), linspace(0,2*pi,s));
[x,y] = pol2cart(theta, rho);
z = zeros(size(x));
subplot(121), imshow(img)
subplot(122), warp(x, y, z, img)
view(2), axis square tight off
Fig. 1 Output when size(C)=[3613 3613]
,
Fig. 2 Output when size(C)=[36130 36130]
Matlab: 2016a
Export_fig: 08/08/16 version
OS: Debian 8.5 64 bit
Linux kernel: 4.6 of backports
Hardware: Asus Zenbook UX303UA
I had a quick look at this, and yeah, something strange is happening. The problem is that you have a border around your image, a border that does not seem to be there when plotting the image
, because its the same color as the background!
If you create your image with
C = rand(100,100);
and then plot it after loading it with imagesc
instead of imshow
you can see this:
That is what it gets translated to an band missing in the polar plot. If you just remove the border around the image of size 1, you'll get a full plot.
My best guess is that somewhere inside export_fig
either your statement % by default, export_fig has cropping
is false or the cropping has some minor bug and takes 1 pixel from the background.