Posted by
Michael Schmid on
Feb 22, 2014; 4:38pm
URL: http://imagej.273.s1.nabble.com/Questions-aboutGaussianBlur-tp5006598p5006635.html
Hi José,
unfortunately I am not aware of any reference for the Gaussian Blur
downscaling algorithm. When I added this to ImageJ (because the Gaussien
Blur with large sigma was too slow for me) I did search the literature for
ways to improve it and tried various methods described in the literature,
but none was satisfying.
So I did the math for downscaling and upscaling myself; it is pretty simple:
- Downscaling already slightly smooths the data.
- Then the line (or column) of the downscaled image is blurred the
conventional way.
- Finally, a kind of 'soft' cubic interpolation algorithm is used to
upscale the line (or column) to the original size.
I just had a look at the kernels used for downscaling and upscaling and
calculate the standard deviation sigma for each of them. Since we have
successive convolutions, one can simply add the squares of the sigma
values of them.
For the upscaling and downscaling kernels, see the makeDownscaleKernel
and makeUpscaleKernel functions.
If I find time I might write a short paper on it, but this won't be in the
immediate future.
---
Concerning point (2), extra lines when blurring in x direction, this can
be explained more easily:
Convolving with a 2D Gaussian is separable, one can first convolve with a
1D Gaussian in x and then with a 1D Gaussian in y.
This is straightforward when convolving the full image. If one wants to
treat only a part of the image, one must make sure that everything that is
an input for blurring in y direction has been blurred in x direction
before. E.g., if we need the output for lines 50-100, and blurring in y
has an overall kernel size of +/- 10 lines, blurring in y needs lines
40-110 as an input. Therefore we first need to blur lines 40-110 as an
input for blurring in y direction.
I hope that this is clear...
Michael
_________________________________________________________________
On Thu, February 20, 2014 13:40, José wrote:
> Hi,
>
> I'm studying the code in
>
https://github.com/imagej/imagej1/blob/master/ij/plugin/filter/GaussianBlur.javaand> I have some questions about some code and the maths behind it:
>
> 1) On lines 229-235 there are some adjustments to sigma based on
> downscaling the image, applying the filter and upscaling again that i
> don't
> fully understand. Could you explain more clearly that adjustments or
> suggest any references i can check about applying the Gaussian blur with
> that downscale-convolve-upscale approach?
>
> 2) On lines 179-186 one can see that, when bluring, extra lines are added
> to the X component but not to the Y component. Why is that?
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html