0
$\begingroup$

I was looking at this particular thread that discusses extending windowing functions for singling function to higher dimension. There is one bit in the accepted answer that I could not get my head around.

So, they create a multi-dimensional windowing function but then they scale the weights in this line.

# scale the window intensities to maintain image intensity
np.power(window, (1.0/data.ndim), output=window)

What is the purpose of doing that?

$\endgroup$
1
$\begingroup$

Without being familiar with the library they use, this pretty much looks to me like a numerical normalizing condition.

Why you need this

This is needed in order to not change the magnitude of the numbers in your data set after filtering. Consider for example a large (multidimensional) region in your image data that exhibits the same value everywhere, e.g. 529. If you filter/smooth this dataset with a filter that has a FWHM that is considerably smaller than the size of the region, you would expect that the value in this region does not change. If you wouldn't include this normalizing condition, this behavior is not guaranteed and you could end up with totally different values... e.g. 1E6 or 0.02 instead of 529. This would seriously complicate further computation, if you had a threshold or so in later processing steps. Or if you converted your data later on... The values would always depend on the filter settings.

A somewhat analytical example

Consider a 1D Gaussian curve. It has a normalization factor $\displaystyle\frac{1}{\sqrt{2\pi}\sigma}$ that is needed to satisfy $\displaystyle\int G(x)\,\textrm{d}x = 1$. For higher dimensions this becomes a little bit more complex: $\displaystyle\frac{1}{\sqrt{(2\pi)^k |\Sigma|}}$, with $|\Sigma|$ being the determinant of the covariance matrix.

A somewhat numerical example

If you do not know the analytical formula, you could also just construct your multidimensional Gaussian without the prefactor, numerically integrate it, and use the resulting factor as the normalization constant.

$\endgroup$

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.