zoukankan      html  css  js  c++  java
  • PS 滤镜——平面坐标变换到极坐标

    %%%  orthogonal coordinate to polar coordinate
    %%%  平面坐标转极坐标
    
    clc;
    clear all;
    close all;
    
    addpath('E:PhotoShop AlgortihmImage ProcessingPS 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);



    原图 


    效果图




  • 相关阅读:
    javascript 数字格式化
    spring-cloud blogs
    rabbitmq python
    centos7下 安装mysql
    hue install
    d3 document
    elastichq 离线安装
    elasticsearch agg
    elastichq auto connect
    Go Hello World!
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9412654.html
Copyright © 2011-2022 走看看