# Estimating number for iterations for gaussian smoothing

I have some data sets on which I applied Gaussian smoothing using [1 4 6 4 1] kernel. In my program I iterated this kernel 50 times on the data sets. But only a few of them could retain their shape, most of them just flattened and lost all the patterns

I want to know is there any way I can estimate the number of iterations of smoothing for each data set ?

Should I be using Normalized Squared Error for the data set and its smoothed version , or maybe use any type of Correlation between the two ?

• Animesh: what are you trying to achieve with the Gaussian smoothing? Applying that kernel 50 times seems like over-kill. You will have virtually nothing left by DC. Can you post a plot of the data (before smoothing)? And perhaps explain what you are expecting to get out of it? That would help readers understand the question better. – Peter K. Apr 26 '13 at 12:20
• Do you have the Signal in both Before and After states with the only question how many times the filter $h$ was applied? – Royi Jun 30 '18 at 14:19

Just compute a gaussian blur kernel for a given sigma, then perform single iteration of 2D convolution or two 1D convolutions (for rows, then for columns or vice versa).

Don't forget to normalize the kernel!

If the kernel comes out too large (it is typically cropped to $\lceil 3\sigma\rceil$), compute the convolution in frequency domain (i.e. IFT(FT(image) *. FT(kernel)) where *. is a point-wise multiplication).

If you don't care about precision, you can apply several iterations of a box filter (the more iterations, the better approximation to Gaussian blur, but the more blurring occurs). You can find a nice definition in SVG Specs. Box filter is separable (can be done as two 1D filterings) and can be implemented with running sum (filter size is not a problem) - this is probably the fastest approximate smoothing method possible.

SInce you have the kernel in integers, it is only approximation to gaussian. To imagine what happens after applying by source_kernel 50 times is equivalent to applying this target_kernel once:

target_kernel = IFT( FT(source_kernel) ^. 50 )

where ^.50 is point-wise power function.

To learn more about the iterative approach, note that Gaussian blurring is equivalent to applying heat equation on an image (imagine how light "hot" pixels diffuse into darker, cooler pixels).

The heat equation is partial differential equation (PDE) in case of images.

You can apply certain amount of smoothing by specifying time amount for simulating heat dissipation and then applying the heat equation in small time steps. I don't know how time amount relates to gaussian $\sigma$, but you probably find more info in any introductory material to diffusion image filtering using PDEs.

Each time step requires computing finite differences at every pixel and applying a small stencil - it is somewhat similar to convolution.

This iterative approach is called implicit filtering and can give you very precise amount of smoothing (the precision is limited by the size of your time steps).

Explicit formulation also exists but require solving very large system of equations.

This kind of filering is rather used for more comlplicated problems like anisotropic diffusion, inverse problems, total variation denoising etc.

• I had applied the gaussian smoothing in order to get the possible patterns the graph. but in some graphs after 50 iterations the graph was smoothed completely i.e. almost flattened. I am asking for a possible method by which I can predict the number iterations for a particular graph. That target_kernel concept is good I will try it, but the explanation did not solve my problem! – Animesh Pandey Apr 29 '13 at 6:44
• I think you can work in frequency domain which reveals how much information is on certain wavelengths and you can measure exactly how much will be removed by the smoothing and design your filter accordingly. I can't provide you the implementation as I have never done anything similar, sorry. – Libor Apr 29 '13 at 17:23