ref_errors#
- pyrost.bin.ref_errors(I_n: numpy.ndarray, W: numpy.ndarray, I0: numpy.ndarray, u: numpy.ndarray, di: numpy.ndarray, dj: numpy.ndarray, ds_y: float, ds_x: float, hval: float, num_threads: int = 1)#
Return the residuals for the reference image regression.
- Parameters
I_n (numpy.ndarray) – Measured intensity frames.
W (numpy.ndarray) – Measured frames’ white-field.
I0 (numpy.ndarray) – Reference image of the sample.
u (numpy.ndarray) – The discrete geometrical mapping of the detector plane to the reference image.
di (numpy.ndarray) – Sample’s translations along the vertical detector axis in pixels.
dj (numpy.ndarray) – Sample’s translations along the fast 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) – Kernel bandwidth in pixels.
num_threads (int) – Number of threads.
- Returns
Residuals array of the reference image regression.
- Return type
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 error metric is given by:
\[\varepsilon_{ref}[i, j] = \sum_{n, i^{\prime}, j^{\prime}} K[i - i_{ref}[n, i^{\prime}, j^{\prime}], j - j_{ref}[n, i^{\prime}, j^{\prime}], h] \; f\left( \frac{I_n[n, i^{\prime}, j^{\prime}] - W[i^{\prime}, j^{\prime}] I_{ref}[i, j]}{\sigma} \right)\]where \(f(x)\) is the Huber loss function and \(K[i, j, h] = \frac{1}{\sqrt{2 \pi}} \exp(-\frac{i^2 + j^2}{h})\) is the Gaussian kernel.
See also
pyrost.bin.KR_reference()
: Description of the reference image estimator.