为什么在此带有export_fig的Matlab Polar演示文稿中存在间隙? [英] Why is there Gap in this Matlab Polar presentation with export_fig?
问题描述
在origo(0,0)到(1,0)的直线上产生间隙的代码,如果C
尺寸达到无穷大,该间隙似乎为零;但是,对于任何大小的C
,我都无法将其缩小到足够小,因此,我认为该伪像可能是由Matlab图形的内部特征或图像数据本身(AnderBiguri)引起的,因为对于img=imread('peppers.png')
来说似乎不会发生.
制作图像的代码,通过 export_fig
存储并映射从笛卡尔到极地发生伪像的地方
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
图. 1 size(C)=[3613 3613]
时输出,
图2 size(C)=[36130 36130]
Fig. 1 Output when size(C)=[3613 3613]
,
Fig. 2 Output when size(C)=[36130 36130]
Matlab:2016a
Export_fig:16年8月8日版本
操作系统:Debian 8.5 64位
Linux内核:4.6个反向端口
硬件:华硕Zenbook UX303UA
Matlab: 2016a
Export_fig: 08/08/16 version
OS: Debian 8.5 64 bit
Linux kernel: 4.6 of backports
Hardware: Asus Zenbook UX303UA
推荐答案
我对此进行了快速浏览,是的,正在发生一些奇怪的事情.问题在于您的图像周围有边框,在绘制image
时似乎没有边框,因为它的颜色与背景相同!
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!
如果您使用
C = rand(100,100);
,然后在用imagesc
而不是imshow
加载后对其进行绘制,您可以看到以下内容:
and then plot it after loading it with imagesc
instead of imshow
you can see this:
这就是它被转换为极坐标图中缺少的谱带的原因.如果仅删除大小为1的图像周围的边框,则会得到完整的图.
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.
我最好的猜测是,在export_fig
内的某个地方,或者您的语句% by default, export_fig has cropping
为假,或者裁剪有一些小错误,并且距背景1个像素.
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.
这篇关于为什么在此带有export_fig的Matlab Polar演示文稿中存在间隙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!