运动模糊
I = imread(‘5.jpg');
>> PSF = fspecial('motion',20,15);J = imfilter(I,PSF,'conv','circular');
figure(2),imshow(J);
imwrite(J, ’55.jpg', 'jpg');
'motion'motion filter
为运动模糊算子,有两个参数,表示摄像物体逆时针方向以theta角度运动了len个像素,len的默认值为9,theta的默认值为0;
H = FSPECIAL('motion',LEN,THETA) returns a filter to approximate,
once convolved with an image, the linear
motion of a camera by LEN pixels,
with an angle of THETA degrees in a counter-clockwise direction.
The filter becomes a vector for horizontal
and vertical motions.
The default LEN is 9, the default THETA is
0, which corresponds to a horizontal motion
of 9 pixels.
散焦模糊
'disk'
circular averaging filter
为圆形区域均值滤波,参数为radius代表区域半径,默认值为5.
H = FSPECIAL('disk',RADIUS) returns a circular averaging filter (pillbox)
within the square matrix of side 2*RADIUS+1.
The default RADIUS is 5.
clc
'计算中......'
I=imread('Lena256.bmp');
r=10;%散焦半径r
PSF=fspecial('disk',r); %得到点扩散函数
I1=imfilter(I,PSF,'symmetric','conv'); %实现散焦模糊
I1=double(I1);
h=[1 1 1;1 -8 1;1 1 1];
I2=filter2(h,I1);
%对微分图I2进行自相关计算
R=xcorr2(I2);
R=R/max(R(:));
figure,surfc(R);
本文介绍了如何使用MATLAB实现两种常见的图像模糊效果:运动模糊和散焦模糊。通过定义不同的滤波器,可以模拟出相机运动时产生的线性运动模糊及通过圆形区域平均滤波实现的散焦效果。


被折叠的 条评论
为什么被折叠?



