我想在极地演示的半个圆周上的polaraxes
对象上使用warp
。没有polaraxes
但warp
close all; clear all; clc;
% https://stackoverflow.com/a/7586650/54964
load clown;
img = ind2rgb(X,map);
[h,w,~] = size(img);
s = min(h,w)/2;
[rho,theta] = meshgrid(linspace(0,s-1,s), linspace(0,pi));
[x,y] = pol2cart(theta, rho);
z = zeros(size(x));
f1=figure();
hax=axes('Parent', f1);
imagesc(img, 'Parent', hax);
box(hax, 'off');
axis(hax, 'off');
set(hax, 'yTickLabel', []);
set(hax, 'xTickLabel', []); % for polar presentation
set(hax, 'Ticklength', [0 0]); % https://stackoverflow.com/a/15529630/54964
f2=figure();
hax2=axes('Parent', f2);
h=warp(x, y, z, img);
view(hax2, 2);
axis(hax2, 'square');
axis(hax2, 'tight');
图1电流输出笛卡尔小丑, 图2半圆周上的极小丑但没有极化, 图3故障排除后的第2节输出(EBH,masi)
使用polaraxes
和warp
的伪代码失败;我只能polaraxes
使用polarplot
,这还不够
hax2=polaraxes('Parent', f2);
h=warp(x,y,z, img);
预期输出:半周的极化
af = figure('Name', 'Do Not Touch');
测试代码以显示隐式命令失败的原因FastPeakFind
测试代码以及更多测试图像,图像绘制和图像方向修复摘要
close all; clear all; clc;
fp=figure('Name', 'Test', ...
'Position',[200 200 851 404],'Resize','off'); % only half circle in polaraxes although warp can do eclipses
ThetaTicks = 0*pi:pi/10:1*pi;
pax = polaraxes( 'ThetaAxisUnits', 'radians', ...
'ThetaLim',[min(ThetaTicks) max(ThetaTicks)],...
'Color','none',...
'GridAlpha',1,...
'GridColor',[1 1 1],...
'ThetaTick',ThetaTicks, ...
'Parent', fp);
af = figure('Name', 'Do Not Touch');
testImages = { 'peppers.png', 'bag.png', 'glass.png', 'circles.png', 'fabric.png', 'testpat1.png', 'office_1.jpg', ...
'onion.png', 'pears.png', 'rice.png', 'westconcordorthophoto.png', 'coins.png' };
imax = axes('Parent', fp, 'Visible', 'off');
for testImage=testImages
I = imread(testImage{1,1});
angleRadians=-pi;
[x, y, z]=makePolar(I, angleRadians);
fp=figure(fp); % put this every time you switch between figures to go back to 'fp'
imax.Children = warp(x, y, z, I);
set(imax,'view',[-180 -90],'Visible','off')
axis(imax,'tight');
pause(1);
% https://stackoverflow.com/a/40006051/54964
Ip=getframe(pax);
Ip=Ip.cdata;
imwrite(Ip, '/tmp/testMasi.png', 'png');
assert(isa(Ip, 'uint8'), sprintf('I is not uint8 but %s', class(Ip)));
p=FastPeakFind(Ip);
imagesc(Ip, 'Parent', imax);
axis(imax, 'off');
hold(imax, 'on');
plot(p(1:2:end),p(2:2:end),'r+', 'Parent', imax);
hold(imax, 'off');
drawnow;
end
图3输出有缺陷的雷达轴;试图在帖子How to integrate Java swing black background toolbar into polaraxes?
中排除故障 Matlab:2016b
操作系统:Debian 8.5 64位
硬件:华硕Zenbook UX303UA
答案 0 :(得分:1)
这里的想法是在极轴上绘制经过扭曲的图像,每个轴使用不同的轴:
% first we create a figure with defined size, because 'polaraxes' are always
% half a circle, and we need to keep the output surface of 'warp' in this
% shape, and not in an ellipse. Switching off the 'Resize' is just an option
fp = figure('Name', 'Test', ...
'Position',[200 200 851 404],'Resize','off');
% Then we define the polaraxes:
ThetaTicks = 0:pi/10:pi; % for the opposite side use pi:pi/10:2*pi
pax = polaraxes( 'ThetaAxisUnits', 'radians', ...
'ThetaLim',[min(ThetaTicks) max(ThetaTicks)],...
'ThetaTick',ThetaTicks, ...
'Parent', fp);
testImages = {'peppers.png', 'bag.png', 'glass.png', 'circles.png',...
'fabric.png', 'testpat1.png', 'office_1.jpg', 'pears.png',...
'rice.png', 'westconcordorthophoto.png', 'coins.png'};
figure(fp) %<-- put this every time you want to bring the focuse back to 'fp'
imax = axes('Parent',fp); % this will be the axes for the image
for testImage = testImages
I = imread(testImage{1,1});
angleRadians = -pi; % for the opposite side use pi
[h,w,~] = size(I);
s = min(h,w)/2;
[rho,theta] = meshgrid(linspace(0,s-1,s), linspace(0,angleRadians,s));
[x,y] = pol2cart(theta, rho);
z = zeros(size(x));
imax.Children = warp(x, y, z, I); % display the image in 3D surface
set(imax,'view',[0 90],'Visible','off'); % rotate to a top view and hide the axes
axis(imax,'tight') % calibrate the image to the figure size
drawnow;
pause(0.5)
end
主要关注点是polaraxes
创建半圆,而warp
创建的半椭圆取决于图形的大小,因此您必须正确设置图形大小。