giant.image_processing.quadric_peak_finder_2d

giant.image_processing.quadric_peak_finder_2d(surface, fit_size=1, blur=True, shift_limit=3)[source]

This function returns a numpy array containing the (x, y) location of the maximum surface value which corresponds to the peak of the fitted quadric surface to subpixel accuracy.

First, this function calls pixel_level_peak_finder_2d() to identify the pixel location of the peak of the correlation surface. It then fits a 2D quadric to the pixels around the peak and solves for the center of the quadric to be the peak value. The quadric equation that is fit is

\[z = Ax^2+By^2+Cxy+Dx+Ey+F\]

where \(z\) is the height of the correlation surface at location \((x,y)\), and \(A--F\) are the coefficients to be fit. The fit is performed in an algebraic least squares sense. The location of the peak of the surface is then given by:

\[\begin{split}\left[\begin{array}{c}x_p \\ y_p\end{array}\right] = \frac{1}{4AB-C^2}\left[\begin{array}{c} CE-2BD\\ CD-2AE\end{array}\right]\end{split}\]

where \((x_p,y_p)\) is the location of the peak.

If the peak is invalid because it is too close to the edge, the fit failed, or the parabolic fit moved the peak too far from the pixel level peak then the result is returned as NaNs.

Parameters:
  • surface (Sequence[Sequence] | ndarray) – A surface, or image, to use

  • fit_size (int) – Number of pixels around the peak that are used in fitting the paraboloid

  • blur (bool) – A flag to indicate whether to apply Gaussian blur to the correlation surface to filter out high frequency noise

  • shift_limit (int) – maximum difference from the pixel level peak to the fitted peak for the fitted peak to be accepted

Returns:

The (x, y) location corresponding to the peak of fitted quadric surface to subpixel accuracy

Return type:

ndarray