1
$\begingroup$

I am reading the implementation of IIR Gaussian blur filter from this link.

In the source code, the coefficients are generated by the following code

/* Calcualte Gaussian Blur Filter Coefficiens
 *  alpha -> smooting gradient depends on sigma
 *  k = ((1-e^-alpha)^2)/(1+2*alpha*e^-alpha - e^-2alpha)
 *  a0 = k; a1 = k*(alpha-1)*e^-alpha; a2 = k*(alpha+1)*e^-alpha; 
 *  a3 = -k*e^(-2*alpha)
 *  b1 = -2*e^-alpha; b2 = e^(-2*alpha)
 */
 void calGaussianCoeff( float sigma,  float *a0, float *a1, float *a2, 
   float *a3, float *b1, float *b2, float *cprev, float *cnext)
{
  float alpha, lamma,  k; 
  // defensive check
  if (sigma < 0.5f)
     sigma = 0.5f;

  alpha = (float) exp((0.726)*(0.726)) / sigma;
  lamma = (float)exp(-alpha);
  *b2 = (float)exp(-2*alpha);
  k = (1-lamma)*(1-lamma)/(1+2*alpha*lamma- (*b2));
  *a0 = k;
  *a1 = k*(alpha-1)*lamma;
  *a2 = k*(alpha+1)*lamma;
  *a3 = -k* (*b2);
  *b1 = -2*lamma;
  *cprev = (*a0 + *a1)/(1+ *b1 + *b2);
  *cnext = (*a2 + *a3)/(1+ *b1 + *b2);
}

Does anyone know where the equation is from?

$\endgroup$
1
$\begingroup$

@Peter K.'s answer is right to the point. You can also have most proposed implementations side-by-side, with comparisons, in Pascal Getreuer, A Survey of Gaussian Convolution Algorithms, Image Processing On Line, 2013, with alternative source code.

$\endgroup$
0
$\begingroup$

Did you try reading the references?

enter image description here

The paper by Deriche is very well-known

$\endgroup$
  • 1
    $\begingroup$ Thanks. From the implementation, I think the author used the algorithm proposed by Ian T. Yong because it operates input image horizontally first and operates previous result vertically. I will read the paper by Deriche carefully. I have another question about initial value of the output. If I use the input value as initial value of the output, artifacts will appear around the boundaries. $\endgroup$ – Jogging Song Sep 4 '15 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.