zoukankan      html  css  js  c++  java
  • PS 滤镜——漩涡 vortex

    %%% Vortex
    %%% 漩涡效果
    
    clc;
    clear all;
    close all;
    
    addpath('E:PhotoShop AlgortihmImage ProcessingPS Algorithm');
    
    I=imread('4.jpg');
    Image=double(I);
    
    [row, col,channel]=size(Image);
    R=floor(max(row, col)/2);
    Image_new=Image;
    Degree=45;
    Center_X=(col+1)/2;
    Center_Y=(row+1)/2;
    
    for i=1:row
        for j=1:col
            x0=j-Center_X;
            y0=Center_Y-i;
            if(x0~=0)
                beta=atan(y0/x0);
                if(x0<0)
                    beta=beta+pi;
                end
            else
                beta=pi/2;
            end
            radius=sqrt(x0*x0+y0*y0);
            beta=beta+radius/Degree;
            x=radius*cos(beta);
            y=radius*sin(beta);
            x=x+col/2;
            y=row/2-y;
            if(x>1 && x<col && y<row && y>1)
                x1=floor(x);
                y1=floor(y);
                p=x-x1;
                q=y-y1;
                Image_new(i,j,:)=(1-p)*(1-q)*Image(y1,x1,:)+p*(1-q)*Image(y1,x1+1,:)...
                    +q*(1-p)*Image(y1+1,x1,:)+p*q*Image(y1+1,x1+1,:);
            end
        end
    end
    figure, imshow(Image_new/255);


    原图 


    效果图


  • 相关阅读:
    python笔记-2
    python笔记-1
    生成列表
    内置函数
    装饰器、包的导入
    python3 编码
    python3 初识函数
    python3 文件读写
    python3 流程控制
    python3 数据类型
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9412648.html
Copyright © 2011-2022 走看看