PS 滤镜——漩涡 vortex

%%% Vortex
%%% 漩涡效果

clc;
clear all;
close all;

addpath('E:\PhotoShop Algortihm\Image Processing\PS 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);

原图

效果图

时间: 2025-01-11 16:09:34

PS 滤镜——漩涡 vortex的相关文章

OpenCV——PS滤镜 漩涡 vertex

// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include <iostream> #include <string> #include "cv.h" #include "highgui.h" #include "cxmat.hpp" #include "cxcore.hpp&quo

PS 滤镜——染色玻璃

%%%% 完成PS 中的染色玻璃滤镜特效 clc; clear all; close all; Image=imread('4.jpg'); Image=double(Image); Gray_Image=rgb2gray(Image/255); [row,col]=size(Gray_Image); S_filter=fspecial('sobel'); G=sqrt(imfilter(Gray_Image, S_filter, 'replicate').^2+... imfilter(Gra

PS 滤镜算法原理 ——马赛克

% method : 利用邻域的任意一点代替当前邻域所有像素点 %%%% mosaic clc; clear all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); Image=imread('4.jpg'); Image=double(Image); size_info=size(Image); height=size_info(1); width=size_info(2); N=11;   % 控制邻域大小

PS 滤镜算法原理——照亮边缘

这个算法原理很简单,对彩色图像的R,G,B 三个通道,分别求梯度,然后将梯度值作为三个通道的值. clc; clear all; Image=imread('4.jpg'); Image=double(Image); R=Image(:,:,1); G=Image(:,:,2); B=Image(:,:,3); R_Gradient=Find_Gradient(R); G_Gradient=Find_Gradient(G); B_Gradient=Find_Gradient(B); Image_

PS 滤镜算法原理——浮雕效果

clc; clear all; Image=imread('4.jpg'); Image=double(Image); R=Image(:,:,1); G=Image(:,:,2); B=Image(:,:,3); p=3;  %% 控制浮雕的强度 %% 控制浮雕的方向 H=[0 0 p 0 0 0 -p 0 0]; Image_new=imfilter(Image,H,'conv')+128; figure, imshow(Image_new/255); 原图 效果图 PS 滤镜算法原理--浮

OpenCV——PS 滤镜, 浮雕效果

具体的算法原理可以参考: PS 滤镜, 浮雕效果 // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include <iostream> #include <string> #include "cv.h" #include "highgui.h" #include "cxmat.hpp" #inc

OpenCV——PS 滤镜, 曝光过度

算法原理可以参考: PS 滤镜,曝光过度 #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include <iostream> #include <string> #include "cv.h" #include "highgui.h" #include "cxmat.hpp" #include "cxcore.hpp"

利用Perlin nosie 完成(PS 滤镜—— 分成云彩)

%%%% Cloud %%%% 利用perlin noise生成云彩 clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); Image=imread('4.jpg'); Image=double(Image); [row,col,layer]=size(Image); baseNoise=rand(row,col); persistance = 0.9; totalA

PS 滤镜——(扭曲)球面化 Spherize

%%%% Spherize clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread('4.jpg'); Image=double(I); [row, col,layer]=size(Image); R=floor(min(row, col)/2); a=row/2; b=col/2; e=a/b; K=pi/2; alpha=1.0; % 控制变形程度