How to rotate polar radius to boundaries?

1 view (last 30 days)
SL
SL on 21 Oct 2016
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
  1. put mirror on the boundaries
  2. mirror the all points outside of the circle
  3. 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
MATLAB: 2016b OS: Debian 8.5 Related: http://mathoverflow.net/q/252770/42613

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!