%%%  orthogonal coordinate to polar coordinate
%%%  平面坐标转极坐标

clc;
clear all;
close all;

addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm');

I=imread('4.jpg');
Image=double(I);

Info_Size=size(Image);
row=Info_Size(1);
col=Info_Size(2);
e=col/row;
R=row/2;
% % % % a=col/2;
% % % % b=row/2;

Image_new(1:row,1:col)=0;
Center_X=(col+1)/2;
Center_Y=(row+1)/2;

for i=1:row
    for j=1:col
            x=j-Center_X;
            y=Center_Y-i;
            theta=atan(y/x*e);
            
            if(x<=0)
                theta=theta+pi;
            end
            if(x>0 && y<=0)
                theta=theta+2*pi;
            end
        
            r1=(y/sin(theta));
            % r2=(x/cos(theta));
            % r1=r2/e;    
            y1=r1*row/R;
            x1=theta*col/(2*pi);
           if(x1>0 && x1<1)
               x=x1+1;
           else
               x=x1;
           end
           y=y1;
           
           if(x>1 && x<col && y<row && y>1)
                x1=floor(x);
                y1=floor(y);
                p=(x-x1);
                q=(y-y1);
                for k=1:3
                Image_new(i,j,k)=(1-p)*(1-q)*Image(y1,x1,k)+p*(1-q)*Image(y1,x1+1,k)...
                            +q*(1-p)*Image(y1+1,x1,k)+p*q*Image(y1+1,x1+1,k);
                end
           end
    end
end

figure, imshow(Image_new/255);



原图 

PS 滤镜——平面坐标变换到极坐标_学习

效果图

PS 滤镜——平面坐标变换到极坐标_学习_02


PS 滤镜——平面坐标变换到极坐标_学习_03