本文介绍了如何在Matlab变形中使用极轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在极地演示文稿的半圆周上的warp对象上使用polaraxes.没有polaraxes但有warp

I want to use polaraxes on the warp object on the half circumference of the polar presentation. Code without polaraxes but with 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)

Fig.1 Current output Cartesian clown,Fig. 2 Polar clown on half circumference but without polaraxes,Fig. 3 Output of Section 2 after troubleshoots (EBH, masi)

使用polaraxeswarp的伪代码未成功;我只能用polarplot进行polaraxes,这在这里还不够

Pseudocode unsuccessfully with polaraxes and warp; I can only do polaraxes with polarplot which is not enough here

hax2=polaraxes('Parent', f2);
h=warp(x,y,z, img);

预期输出:半圆周上的极轴

Expected output: polaraxes on the half circumference

  1. pax = polaraxes,2.循环,3.将warp(I)导入pax-已添加循环
  2. 隐式命令视图和轴失败-添加了测试代码af = figure('Name', 'Do Not Touch');以显示隐式命令失败的原因
  3. 具有FastPeakFind和更多测试图像的测试代码,图像绘制和图像方向修复
  1. pax=polaraxes, 2. loop, 3. warp(I) into pax - looping added
  2. Implicit commands view and axis fail - test code added af = figure('Name', 'Do Not Touch'); to show why the implicit commands fail
  3. Test code with FastPeakFind and more test images, Image drawing and Image orientation fixes

摘要

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中的输出,其中雷达轴有故障;尝试在线程如何将Java摆动黑色背景工具栏集成到Polaraxes中来对其进行故障排除?

Output in Fig. 3 where buggy radar axis; trying to troubleshoot it in the thread How to integrate Java swing black background toolbar into polaraxes?

Matlab:2016b
操作系统:Debian 8.5 64位
硬件:华硕Zenbook UX303UA

Matlab: 2016b
OS: Debian 8.5 64 bit
Hardware: Asus Zenbook UX303UA

推荐答案

此处的想法是在极轴上绘制变形图像,每个极轴使用不同的轴:

The idea here is plotting the warpped image on a polar axes, using different axes for each:

% 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创建半椭圆,这取决于图形的尺寸,因此必须正确设置图形尺寸.

The main cavet is polaraxes creates half circle, while the warp creates half ellipse that depends on the size of the figure, so you have to set correctly the figure size.

这篇关于如何在Matlab变形中使用极轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 04:55