tr_gsearch#

pyrost.bin.tr_gsearch(I_n: numpy.ndarray, W: numpy.ndarray, sigma: numpy.ndarray, I0: numpy.ndarray, u: numpy.ndarray, di: numpy.ndarray, dj: numpy.ndarray, sw_y: float, sw_x: float, grid_size: int, ds_y: float, ds_x: float, loss: str = 'Huber', num_threads: int = 1)#

Update the sample pixel translations by minimizing total mean-squared-error (:math:$MSE_{total}$). Perform a grid search within the search window of sw_y size in pixels for sample translations along the vertical axis, and of sw_x size in pixels for sample translations along the horizontal axis in order to minimize the total MSE.

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

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

  • sigma (numpy.ndarray) – 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) – 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.

  • sw_y (float) – Search window size in pixels along the vertical detector axis.

  • sw_x (float) – Search window size in pixels along the horizontal detector axis.

  • grid_size (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

Updated sample pixel translations.

Return type

numpy.ndarray

Notes

The error metric as a function of sample shifts is given by:

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

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