1. 程式人生 > >PS 濾鏡——運動模糊

PS 濾鏡——運動模糊

%%%%%  motion blur
clc;
clear all;
close all;
Image=imread('4.jpg');
Image=double(Image);
theta=pi/4;
len=20;
row=floor(len*sin(theta))+1;
col=floor(len*cos(theta))+1;
motion_f1(1:row,1:col)=0;
K=tan(theta);
center_x=col/2;
center_y=row/2;

for i=1:row
    for j=1:col
        x=j-center_x;
        y=center_y-i;
        Dis=abs(K*x-y)/sqrt(K*K+1);
        motion_f1(i,j)=max(1-Dis,0);
    end
end

motion_f1=motion_f1/sum(motion_f1(:));
Image1=imfilter(Image,motion_f1,'replicate','conv');
imshow(Image1/255);

motion_filter=fspecial('motion',20,0);
Image2=imfilter(Image,motion_filter,'replicate','conv');
figure,

imshow(Image2/255);

原圖 


效果圖 


效果圖