function_stdEst2D

PURPOSE ^

Estimate noise standard deviation (AWGN model)

SYNOPSIS ^

function dev=function_stdEst2D(z,method)

DESCRIPTION ^

 Estimate noise standard deviation (AWGN model)

 dev = function_stdEst2D(z,method)

 OUTPUT
 ------
 dev    :  estimated noise standard deviation

 INPUTS
 ------
 z      :  noisy observation (1D vector or 2D image)
 method :  method to attenuate signal (optional input)
             0  standard shifted differences
             1  cascaded horizontal-vertical shifted differences
             2  wavelet domain estimation  (DEFAULT)
             3  wavelet domain estimation with boundary removal
             4  Immerkaer's method  (FASTEST)

             7  Immerkaer's method with Daubechies-based Laplacian
             8  Blockwise Immerkaer's method with Daubechies-based Laplacian


  methods 0-3 are based on the Median of Absolute Deviation (MAD)
  technique, whereas method 4 is based on Laplacian filtering

 Alessandro Foi - Tampere University of Technology - 2005-2006
 -----------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 % Estimate noise standard deviation (AWGN model)
0003 %
0004 % dev = function_stdEst2D(z,method)
0005 %
0006 % OUTPUT
0007 % ------
0008 % dev    :  estimated noise standard deviation
0009 %
0010 % INPUTS
0011 % ------
0012 % z      :  noisy observation (1D vector or 2D image)
0013 % method :  method to attenuate signal (optional input)
0014 %             0  standard shifted differences
0015 %             1  cascaded horizontal-vertical shifted differences
0016 %             2  wavelet domain estimation  (DEFAULT)
0017 %             3  wavelet domain estimation with boundary removal
0018 %             4  Immerkaer's method  (FASTEST)
0019 %
0020 %             7  Immerkaer's method with Daubechies-based Laplacian
0021 %             8  Blockwise Immerkaer's method with Daubechies-based Laplacian
0022 %
0023 %
0024 %  methods 0-3 are based on the Median of Absolute Deviation (MAD)
0025 %  technique, whereas method 4 is based on Laplacian filtering
0026 %
0027 % Alessandro Foi - Tampere University of Technology - 2005-2006
0028 % -----------------------------------------------------------------------
0029 
0030 function dev=function_stdEst2D(z,method)
0031 
0032 if nargin==1
0033     method=2;
0034 end
0035 if min(abs(method-[0 1 2 3 4 7 8]))>0
0036     disp(' ');disp('   !!!!!   Second argument must be either 0, 1, 2, 3, 4, 7, or 8.  (see help)');disp(' ');
0037     return
0038 end
0039 if ndims(z)>2
0040     disp(' ');disp('   !!!!!   Input has to be 1D vector or 2D image.  ');disp(' ');
0041     return
0042 end
0043 size_z=size(z);
0044 if min(size_z(1:2))==1
0045     z=z(:);
0046     if method==0||method==1
0047         z1=circshift(z,[1 0]);
0048         dz=abs(z(2:end,:)-z1(2:end,:));
0049         dev=median(dz(:))/(0.6745*sqrt(2));
0050     end
0051     if method==2
0052         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008]';
0053         wav_det=conv2(z,daub6kern,'same');
0054         dev=median(abs(wav_det(:)))/.6745;
0055     end
0056     if method==3
0057         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008]';
0058         wav_det=conv2(z,daub6kern,'valid');
0059         dev=median(abs(wav_det(:)))/.6745;
0060     end
0061     if method==4
0062         LAPL=[1 -2 1]';
0063         LAPL=LAPL*sqrt(pi/2/sum(LAPL(:).^2));
0064         YY=conv2(z,LAPL,'valid');
0065         dev=mean(abs(YY(:)));
0066     end
0067     if method==7
0068         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008]';
0069         LAPL=conv(daub6kern,daub6kern);
0070         YY=conv2(z,daub6kern*sqrt(pi/2/sum(LAPL(:).^2)),'valid');
0071         YY=conv2(YY,daub6kern,'valid');
0072         dev=mean(abs(YY(:)));
0073     end
0074     if method==8
0075         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008]';
0076         LAPL=conv2(daub6kern,daub6kern);
0077         YY=conv2(z,daub6kern*sqrt(pi/2/sum(LAPL(:).^2)),'valid');
0078         YY=conv2(YY,daub6kern,'valid');
0079         LL=16;
0080         NB1=floor(size(YY,1)/LL);
0081         YY=YY(1:NB1*LL);
0082         dev=median(mean(abs(reshape(YY,[LL NB1])),1));
0083     end
0084 else
0085     if method==0
0086         z1=circshift(z,[1 0]);
0087         dz=abs(z(2:end,:)-z1(2:end,:));
0088         dev=median(dz(:))/(0.6745*sqrt(2));
0089         z2=circshift(z,[0 1]);
0090         dz=abs(z(:,2:end)-z1(:,2:end));
0091         dev=0.5*dev+0.5*median(dz(:))/(0.6745*sqrt(2));
0092     end
0093     if method==1
0094         z1=circshift(z,[1 0]);
0095         dz=z(2:end,:)-z1(2:end,:);
0096         dev=median(dz(:))/(0.6745*sqrt(2));
0097         z1=circshift(dz,[0 1]);
0098         dz=abs(dz(:,2:end)-z1(:,2:end));
0099         dev=median(dz(:))/(0.6745*2);
0100     end
0101     if method==2
0102         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008];
0103         daub6kern=daub6kern(end:-1:1);
0104         wav_det=conv2(z,daub6kern,'same');
0105         wav_det=conv2(wav_det,daub6kern','same');
0106         dev=median(abs(wav_det(:)))/.6745;
0107     end
0108     if method==3
0109         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008];
0110         wav_det=conv2(z,daub6kern,'valid');
0111         wav_det=conv2(wav_det,daub6kern','valid');
0112         dev=median(abs(wav_det(:)))/.6745;
0113     end
0114     if method==4
0115         LAPL=[1 -2 1;-2 4 -2;1 -2 1];
0116         LAPL=LAPL*sqrt(pi/2/sum(LAPL(:).^2));
0117         YY=conv2(z,LAPL,'valid');
0118         dev=mean(abs(YY(:)));
0119     end
0120     if method==7
0121 
0122         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008];
0123         LAPL=conv2(daub6kern,daub6kern);
0124         LAPL=conv2(LAPL,daub6kern');
0125         LAPL=conv2(LAPL,daub6kern');
0126 
0127         YY=conv2(z,daub6kern*sqrt(pi/2/sum(LAPL(:).^2)),'valid');
0128         YY=conv2(YY,daub6kern,'valid');
0129         YY=conv2(YY,daub6kern','valid');
0130         YY=conv2(YY,daub6kern','valid');
0131         dev=mean(abs(YY(:)));
0132     end
0133     if method==8
0134 
0135         daub6kern=[0.03522629188571 0.08544127388203 -0.13501102001025 -0.45987750211849 0.80689150931109 -0.33267055295008];
0136         LAPL=conv2(daub6kern,daub6kern);
0137         LAPL=conv2(LAPL,daub6kern');
0138         LAPL=conv2(LAPL,daub6kern');
0139         YY=conv2(z,daub6kern*sqrt(pi/2/sum(LAPL(:).^2)),'valid');
0140         YY=conv2(YY,daub6kern,'valid');
0141         YY=conv2(YY,daub6kern','valid');
0142         YY=conv2(YY,daub6kern','valid');
0143         LL=8;
0144         NB1=floor(size(YY,1)/LL);
0145         NB2=floor(size(YY,2)/LL);
0146         YY=YY(1:NB1*LL,1:NB2*LL);
0147         dev=median(mean(abs(YY(repmat(reshape(repmat([1:LL],[LL 1])'+repmat([0:LL*NB1:LL*LL*NB1-1]',[1 LL])',[LL*LL 1]) ,[1 NB1*NB2])+repmat(reshape(repmat([0:LL:NB1*LL-1],[NB2 1])+repmat(NB1*LL*[0:LL:NB2*LL-1]',[1 NB1]),[1 NB1*NB2]),[LL*LL 1]))),1));
0148 
0149     end
0150 end
0151

Generated on Fri 07-Mar-2014 13:28:33 by m2html © 2005