KR_reference#
- pyrost.bin.KR_reference(I_n: numpy.ndarray, W: numpy.ndarray, u: numpy.ndarray, di: numpy.ndarray, dj: numpy.ndarray, ds_y: float, ds_x: float, hval: float, return_nm0: bool = True, num_threads: int = 1)#
Generate an unabberated reference image of the sample based on the pixel mapping u and the measured data I_n using the Kernel regression.
- Parameters
I_n (numpy.ndarray) – Measured intensity frames.
W (numpy.ndarray) – Measured frames’ white-field.
u (numpy.ndarray) – The discrete geometrical mapping of the detector plane to the reference image.
di (numpy.ndarray) – Initial sample’s translations along the vertical detector axis in pixels.
dj (numpy.ndarray) – Initial sample’s translations along the horizontal detector axis in pixels.
ds_y (float) – Sampling interval of reference image in pixels along the vertical axis.
ds_x (float) – Sampling interval of reference image in pixels along the horizontal axis.
hval (float) – Gaussian kernel bandwidth in pixels.
return_nm0 (bool) – If True, also returns the lower bounds (n0, m0) of the reference image in pixels.
num_threads (int) – Number of threads.
- Returns
I0 : Reference image array.
n0 : The lower bounds of the vertical detector axis of the reference image at the reference frame in pixels. Only provided if return_nm0 is True.
m0 : The lower bounds of the horizontal detector axis of the reference image at the reference frame in pixels. Only provided if return_nm0 is True.
- Return type
A tuple of three elements (I0, n0, m0). The elements are the following
Notes
The pixel mapping u maps the intensity measurements from the detector plane to the reference plane as follows:
\[i_{ref}[n, i, j] = u[0, i, j] + di[n], \; j_{ref}[n, i, j] = u[1, i, j] + dj[n]\]The reference image profile \(I_{ref}[ii, jj]\) is obtained with the kernel regression extimator as follows:
\[I_{ref}[i, j] = \frac{\sum_{n, i^{\prime}, j^{\prime}} K[i - i_{ref}[n, i^{\prime}, j^{\prime}], j - j_{ref}[n, i^{\prime}, j^{\prime}], h] \; W[i^{\prime}, j^{\prime}] I[n, i^{\prime}, j^{\prime}]} {\sum_{n, i^{\prime}, j^{\prime}} K[i - i_{ref}[n, i^{\prime}, j^{\prime}], j - j_{ref}[n, i^{\prime}, j^{\prime}], h] \; W^2[i^{\prime}, j^{\prime}]}\]where \(K[i, j, h] = \frac{1}{\sqrt{2 \pi}} \exp(-\frac{i^2 + j^2}{h})\) is the Gaussian kernel.