How to rotate polar radius to boundaries?
1 次查看(过去 30 天)
显示 更早的评论
I am thinking if there is any method to rotate origo to boundaries and boundaries to origo. The related thread has the relevant code and example about the situation. My pseudocode is
- put mirror on the boundaries
- mirror the all points outside of the circle
- shrinkage now the empty space in the circle; the points should now be in the circle
I think there exists mathematically more rigorous way to do it. The related thread is about Mathematics of the case. However, there may be already something relevant integrated in MATLAB.
Code
close all; clear all; clc;
% http://stackoverflow.com/q/40030096/54964
fp2 = figure('Name', 'Test YX', ...
'Position',[200 200 851 404],'Resize','off'); % only half circle in polaraxes although warp can do eclipses
ThetaTicks = 0*pi:pi/10:2*pi;
pax2 = polaraxes( 'ThetaAxisUnits', 'radians', ...
'ThetaLim',[min(ThetaTicks) max(ThetaTicks)],...
'Color','none',...
'GridAlpha',1,...
'GridColor',[1 1 1],...
'ThetaTick',ThetaTicks, ...
'Parent', fp2);
I = imread('https://i.stack.imgur.com/6lZd9.png');
imax2 = axes('Parent', fp2, 'Visible', 'off');
angleRadians=-2*pi;
[x, y, z]=makePolar(I, angleRadians);
imax2.Children = warp(x, y, z, I);
set(imax2,'view',[-180 -90],'Visible','off')
function [x, y, z]=makePolar(img, angleRadians)
% http://stackoverflow.com/a/7586650/54964
[h,w,~] = size(img);
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));
end
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!