如何在 Matlab warp 中使用极轴?
How to use polar axes with Matlab warp?
我想在warp
对象上使用polaraxes
在极地演示文稿的半圆周上。没有 polaraxes
但有 warp
的代码
close all; clear all; clc;
%
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]); %
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
伪代码失败;我只能用 polarplot
做 polaraxes
,这里还不够
hax2=polaraxes('Parent', f2);
h=warp(x,y,z, img);
预期输出:半圆周上的极轴
2 测试 EBH 的提议
- pax=polaraxes, 2. loop, 3. warp(I) into pax - 添加循环
- 隐式命令视图和轴失败 - 添加了测试代码
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);
%
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
OS:Debian 8.5 64 位
硬件:华硕 Zenbook UX303UA
这里的想法是在极轴上绘制扭曲图像,每个轴使用不同的轴:
% 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
创建半椭圆取决于图形的大小,因此您必须正确设置图形大小。
我想在warp
对象上使用polaraxes
在极地演示文稿的半圆周上。没有 polaraxes
但有 warp
close all; clear all; clc;
%
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]); %
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
伪代码失败;我只能用 polarplot
做 polaraxes
,这里还不够
hax2=polaraxes('Parent', f2);
h=warp(x,y,z, img);
预期输出:半圆周上的极轴
2 测试 EBH 的提议
- pax=polaraxes, 2. loop, 3. warp(I) into pax - 添加循环
- 隐式命令视图和轴失败 - 添加了测试代码
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);
%
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
OS:Debian 8.5 64 位
硬件:华硕 Zenbook UX303UA
这里的想法是在极轴上绘制扭曲图像,每个轴使用不同的轴:
% 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
创建半椭圆取决于图形的大小,因此您必须正确设置图形大小。