How to use polar axes with Matlab warp?

后端 未结 1 496
悲哀的现实
悲哀的现实 2020-12-11 14:23

I want to use polaraxes on the warp object on the half circumference of the polar presentation. Code without polaraxes but with

相关标签:
1条回答
  • 2020-12-11 14:50

    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
    

    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.

    0 讨论(0)
提交回复
热议问题