# Recursive Gaussian Deriche

**URL:** <https://forums.developer.nvidia.com/t/recursive-gaussian-deriche/8064>\
**Category:** CUDA Programming and Performance\
**Created:** [March 2, 2009, 2:28pm UTC](https://forums.developer.nvidia.com/t/recursive-gaussian-deriche/8064 "2009-03-02T14:28:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TranceMokes](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TranceMokes](https://forums.developer.nvidia.com/u/TranceMokes)\
**Post date:** [March 2, 2009, 2:28pm UTC](https://forums.developer.nvidia.com/t/recursive-gaussian-deriche/8064/1 "2009-03-02T14:28:45Z")

</div>

Hi nvidia and members,

For my thesis i have to expand the derich algorithm to the 4th order.

In the example of Recursive gaussian there is deriche method of the second order but not of 3rd of 4th order.

So my question to you guys is, how can i make a 3rd order deriche with this code?

I dont see also not the logic behind the deriche code if i run the code i get the follwing results

\*\*\*for order 0: a1 + a2 + a3 + a4 != 0 (is this true)

\*\*\*for order 1 & 2: a1 + a2 + a3 + a4 = 0 (is this coincidence)  
also the sum of coefp & coefn is equal to 0 ???

I want to understand the logic behind this code. How the values of the coefficients (b0 b1 a1 a2 a3 a4) are calculate. I looked up many papers/google/CImg/etc, but i cant find any information about those coefficients.

Can someone can help me about this issue?

Best regards,  
Jorn De Baerdemaeker

---

<div class="post-metadata">

**Author:** ![Simon\_Green](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Simon\_Green](https://forums.developer.nvidia.com/u/Simon_Green)\
**Post date:** [March 2, 2009, 8:14pm UTC](https://forums.developer.nvidia.com/t/recursive-gaussian-deriche/8064/2 "2009-03-02T20:14:02Z")

</div>

This isn’t really a CUDA question, but this paper describes an improved and simpler recursive Gaussian:  
[http://citeseerx.ist.psu.edu/viewdoc/summa](http://citeseerx.ist.psu.edu/viewdoc/summa)…=10.1.1.12.2826

---

<div class="post-metadata">

**Author:** ![TranceMokes](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TranceMokes](https://forums.developer.nvidia.com/u/TranceMokes)\
**Post date:** [March 2, 2009, 8:24pm UTC](https://forums.developer.nvidia.com/t/recursive-gaussian-deriche/8064/3 "2009-03-02T20:24:11Z")

</div>

> [@](#):
>
> This isn’t really a CUDA question, but this paper describes an improved and simpler recursive Gaussian:
> 
> http://citeseerx.ist.psu.edu/viewdoc/summa…=10.1.1.12.2826

Thx for the reply,

I’m just wondering why they are using this method in the Recurisve Gaussian (SDK Example):

> [@](#):
>
> const float
> 
> ```
> nsigma = sigma < 0.1f ? 0.1f : sigma,
> 
> alpha = 1.695f / nsigma,
> 
> ema = (float)std::exp(-alpha),
> 
> ema2 = (float)std::exp(-2*alpha),
> 
> b1 = -2*ema,
> 
> b2 = ema2;
> 
> ```
> 
> float a0 = 0, a1 = 0, a2 = 0, a3 = 0, coefp = 0, coefn = 0;
> 
> ```
> switch (order) {
> 
> case 0: {
> 
> const float k = (1-ema)*(1-ema)/(1+2*alpha*ema-ema2);
> 
> a0 = k;
> 
> a1 = k*(alpha-1)*ema;
> 
> a2 = k*(alpha+1)*ema;
> 
> a3 = -k*ema2;
> 
> } break;
> 
> ```
> 
> case 1: {
> 
> ```
> const float k = (1-ema)*(1-ema)/ema;
> 
> a0 = k*ema;
> 
> a1 = a3 = 0;
> 
> a2 = -a0;
> 
> } break;
> 
> ```
> 
> case 2: {
> 
> ```
> const float
> 
> ea = (float)std::exp(-alpha),
> 
> k = -(ema2-1)/(2*alpha*ema),
> 
> kn = (-2*(-1+3*ea-3*ea*ea+ea*ea*ea)/(3*ea+1+3*ea*ea+ea*ea*ea));
> 
> a0 = kn;
> 
> a1 = -kn*(1+k*alpha)*ema;
> 
> a2 = kn*(1-k*alpha)*ema;
> 
> a3 = -kn*ema2;
> 
> } break;
> 
> ```
> 
> default:
> 
> ```
> fprintf(stderr, "gaussianFilter: invalid order parameter!\n");
> 
> return;
> 
> }
> 
> coefp = (a0+a1)/(1+b1+b2);
> 
> coefn = (a2+a3)/(1+b1+b2);
> 
> ```

if anyone can helping me with the explanation with the above code, it would be great :)

Thanks in advance

Jorn De Baerdemaeker

---

<div class="post-metadata">

**Author:** ![Simon\_Green](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Simon\_Green](https://forums.developer.nvidia.com/u/Simon_Green)\
**Post date:** [March 2, 2009, 8:29pm UTC](https://forums.developer.nvidia.com/t/recursive-gaussian-deriche/8064/4 "2009-03-02T20:29:27Z")

</div>

That code was based on the code in the CImg library, so you would be better off asking them!

---

<div class="post-metadata">

**Author:** ![TranceMokes](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TranceMokes](https://forums.developer.nvidia.com/u/TranceMokes)\
**Post date:** [March 3, 2009, 10:06am UTC](https://forums.developer.nvidia.com/t/recursive-gaussian-deriche/8064/5 "2009-03-03T10:06:50Z")

</div>

> [@](#):
>
> That code was based on the code in the CImg library, so you would be better off asking them!

Maybe i did it already. But i think Nvidia or CImg can’t give me the answer.

Because the code of CImg is based on DericheFilter.h.

ftp://ftp-sop.inria.fr/odyssee/Team/Jerom…icheFilter.html

Grtz,

Jorn
