ref_total_error#

pyrost.bin.ref_total_error(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 mean residual for the reference image regression.

Parameters
  • I_n (numpy.ndarray) – Measured intensity frames.

  • W (numpy.ndarray) – Measured frames’ white-field.

  • sigma – The standard deviation of I_n.

  • 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

Mean residual value.

Return type

float

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.