fractal-mosaics/reference/upstream-matlab/polar_conversion.m
copilot 5bfeae238d Add Python fractal-mosaic CLI and unpack MATLAB reference
Fork of s-ben/Fractal-Mosaics for Tower mosaik inbox: GPL license,
upstream .m sources under reference/, RST placement with CBIR +
log-polar hints, edge alpha, profiles wenig/mittel/dicht, no recolor.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 17:03:12 +02:00

27 lines
590 B
Matlab
Executable file

function polar = polar_conversion(A)
A_dim = size(A); % get dimensions of A
center = A_dim/2; % get center of image coordinates
% ---------- calculate polar coordinates -------------
theta = linspace(0,2*pi,A_dim(1)+1); theta(end) = [];
% d = min([A_dim(1)-center(1) center(1)-1 A_dim(2)-center(2) center(2)-1]);
rho = linspace(0, center(1)-1,A_dim(2))';
% convert polar coordinates to cartesian coordinates and center
xx = rho*cos(theta) + center(1);
yy = rho*sin(theta) + center(2);
xx = double(xx);
yy = double(yy);
polar=interp2(double(A),xx,yy);