運動模糊
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);