1. 程式人生 > >影象處理-線性濾波-2 影象微分(1、2階導數和拉普拉斯運算元)

影象處理-線性濾波-2 影象微分(1、2階導數和拉普拉斯運算元)

更復雜些的濾波運算元一般是先利用高斯濾波來平滑,然後計算其1階和2階微分。由於它們濾除高頻和低頻,因此稱為帶通濾波器(band-pass filters)。

在介紹具體的帶通濾波器前,先介紹必備的影象微分知識。

1 一階導數

連續函式,其微分可表達為image ,或image                         (1.1)

對於離散情況(影象),其導數必須用差分方差來近似,有

                                   image,前向差分 forward differencing                  (1.2)

                                   

image ,中心差分 central differencing                     (1.3)

1)前向差分的Matlab實現

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 function dimg = mipforwarddiff(img,direction) % MIPFORWARDDIFF     Finite difference calculations
% %   DIMG = MIPFORWARDDIFF(IMG,DIRECTION) % %  Calculates the forward-difference for a given direction %  IMG       : input image %  DIRECTION : 'dx' or'dy' %  DIMG      : resultant image % %   See also MIPCENTRALDIFF MIPBACKWARDDIFF MIPSECONDDERIV %   MIPSECONDPARTIALDERIV
%   Omer Demirkaya, Musa Asyali, Prasana Shaoo, ... 9/1/06 %   Medical Image Processing Toolbox imgPad = padarray(img,[1 1],'symmetric','both');%將原影象的邊界擴充套件 [row,col] = size(imgPad); dimg = zeros(row,col); switch (direction)   case 'dx', dimg(:,1:col-1) = imgPad(:,2:col)-imgPad(:,1:col-1);%x方向差分計算, case 'dy', dimg(1:row-1,:) = imgPad(2:row,:)-imgPad(1:row-1,:); otherwise, disp('Direction is unknown'); end; dimg = dimg(2:end-1,2:end-1);

2)中心差分的Matlab實現

1 2 3 4