pm_gsearch#

pyrost.bin.pm_gsearch(I_n: numpy.ndarray, W: numpy.ndarray, I0: numpy.ndarray, sigma: numpy.ndarray, u0: numpy.ndarray, di: numpy.ndarray, dj: numpy.ndarray, search_window: Sequence[float], grid_size: Sequence[int], ds_y: float, ds_x: float, num_threads: int = 1)#

Update the pixel mapping by minimizing mean-squared-error (MSE). Perform a grid search within the search window of sw_y, sw_x size along the vertical and fast axes accordingly in order to minimize the MSE at each point of the detector grid separately.

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

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

  • I0 (numpy.ndarray) – Reference image of the sample.

  • sigma (numpy.ndarray) – The standard deviation of I_n.

  • u – 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.

  • search_window (Sequence[float]) – Search window size in pixels along the vertical detector axis.

  • grid_size (Sequence[int]) – Grid size along one of the detector axes. The grid shape is then (grid_size, grid_size).

  • 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.

  • num_threads (int) – Number of threads.

Returns

  • u : Updated pixel mapping array.

  • derr : Error decrease for each pixel in the detector grid.

Return type

A tuple of two elements (u, derr). The elements are the following

Notes

The error metric as a function of pixel mapping displacements is given by:

\[\varepsilon_{pm}[i, j, i^{\prime}, j^{\prime}] = \frac{1}{N} \sum_{n = 0}^N f\left( \frac{I[n, i, j] - W[i, j] I_{ref}[u[0, i, j] + i^{\prime} - di[n], u[1, i, j] + j^{\prime} - dj[n]]}{\sigma} \right)\]

where \(f(x)\) is the Huber loss function.