window#
This module contains the window functions for image preprocessing.
The window functions can be used to preprocess the input images before calculating the image structure function.
For example:
import fastddm as fddm
# load your images here
img_seq = fddm.read_images(...)
# preprocess the images using a Blackman-Harris window
window = fddm.window.blackman_harris(img_seq.shape)
# this would modify the images directly...
# img_seq = (img_seq * window).astype(img_seq.dtype)
# ...but you can also pass the window to the ddm function
dqt = fddm.ddm(img_seq, range(1, len(img_seq)), window=window)
(Source code
, png
, hires.png
, pdf
)
- fastddm.window.blackman(shape: Tuple[int, ...]) ndarray #
Blackman window.
In the 1D case, the equation for the periodic three-term exact Blackman window of length N reads:
\[w(x) = \sum_{j=0}^2 (-1)^j a_j \cos{\left( \frac{2 \pi j x}{N} \right)}\]where \(0 \le x < N\) and:
\[\begin{split}a_0 &= 7938 / 18608 \simeq 0.42659071 \\ a_1 &= 9240 / 18608 \simeq 0.4965062 \\ a_2 &= 1430 / 18608 \simeq 0.07684867 .\end{split}\]The 2D window function then is given by \(W(x,y)=w(x)w(y)\).
See: F.J. Harris, Proc. IEEE 66, 51 (1978).
- Parameters:
shape (Tuple[int, ...]) – Image (or sequence) shape. Last two values are used.
- Returns:
A Blackman window.
- Return type:
- fastddm.window.blackman_harris(shape: Tuple[int, ...]) ndarray #
Blackman-Harris window.
In the 1D case, the equation for the periodic four-term Blackman-Harris window of length N reads:
\[w(x) = \sum_{j=0}^3 (-1)^j a_j \cos{\left( \frac{2 \pi j x}{N} \right)}\]where \(0 \le x < N\) and:
\[\begin{split}a_0 &= 0.3635819 \\ a_1 &= 0.4891775 \\ a_2 &= 0.1365995 \\ a_3 &= 0.0106411 .\end{split}\]The 2D window function then is given by \(W(x,y)=w(x)w(y)\).
See: F. Giavazzi et al., Eur. Phys. J. E 40, 97 (2017).
- Parameters:
shape (Tuple[int, ...]) – Image (or sequence) shape. Last two values are used.
- Returns:
A Blackman-Harris window.
- Return type: