On Feb 4, 2008 1:27 PM, Alastair M. Robinson
> Hi,
> I may be missing something obvious here, but I'm trying to understand
> the workings of the Gaussian Blur plugin, since I need to implement
> something similar myself, and either there's something screwy here, or
> there's something obvious I'm missing.

I'm not going to try to parse the code in an email message, but
although it is quite difficult to read, it is set up to avoid referring
to any unallocated memory (otherwise it would crash, or at least
generate errors in valgrind).

The crucial fact, which may help you understand the code, is that
a 2D Gaussian blur can be implemented by doing two 1D Gaussian
blurs, first vertically, then horizontally.  Thus, the code starts out
by doing a 1D blur on  each column of the image.  When this
is finished, the result is processed by independently blurring each
row.  It is a remarkable theorem that this sequence of two
1D convolutions gives exactly the same result as the full 2D
convolution -- at least, it gives the same result if the region is
rectangular and all pixels are fully selected and equally weighted.

Basically this happens because the kernel of the 2D Gaussian
blur factors:  exp (-(x^2 + y^2)) = exp (-x^2) * exp (-y^2).
This allows the double integral in the 2D convolution to be
factored into a product of two single integrals, over x and y.
Unfortunately, I don't have a good reference to point you to,
but the method is very widely used.  (IIR and RLE are simply
tricks for doing a 1D convolution that produce speedups in
some common situations.)

  -- Bill
Gimp-developer mailing list

Reply via email to