Centroid Algorithm¶
Utilities for finding peak in an image.
- Author
Mihai Cara (for help, contact HST Help Desk)
- License
-
subpixal.centroid.find_peak(image_data, xmax=None, ymax=None, peak_fit_box=5, peak_search_box=None, mask=None)[source]¶ Find location of the peak in an array. This is done by fitting a second degree 2D polynomial to the data within a
peak_fit_boxand computing the location of its maximum. Whenxmaxandymaxare bothNone, an initial estimate of the position of the maximum will be performed by searching for the location of the pixel/array element with the maximum value. This kind of initial brute-force search can be performed even whenxmaxandymaxare provided but when one suspects that these input coordinates may not be very accurate by specifying an expanded brute-force search box through parameterpeak_search_box.- Parameters
- image_datanumpy.ndarray
Image data.
- xmaxfloat, None, optional
Initial guess of the x-coordinate of the peak. When both
xmaxandymaxareNone, the initial (pre-fit) estimate of the location of the peak will be obtained by a brute-force search for the location of the maximum-value pixel in the entireimage_dataarray, regardless of the value ofpeak_search_boxparameter.- ymaxfloat, None, optional
Initial guess of the x-coordinate of the peak. When both
xmaxandymaxareNone, the initial (pre-fit) estimate of the location of the peak will be obtained by a brute-force search for the location of the maximum-value pixel in the entireimage_dataarray, regardless of the value ofpeak_search_boxparameter.- peak_fit_boxint, tuple of int, optional
Size (in pixels) of the box around the input estimate of the maximum (given by
xmaxandymax) to be used for quadratic fitting from which peak location is computed. If a single integer number is provided, then it is assumed that fitting box is a square with sides of length given bypeak_fit_box. If a tuple of two values is provided, then first value indicates the width of the box and the second value indicates the height of the box.- peak_search_boxstr {‘all’, ‘off’, ‘fitbox’}, int, tuple of int, None,optional
Size (in pixels) of the box around the input estimate of the maximum (given by
xmaxandymax) to be used for brute-force search of the maximum value pixel. This search is performed before quadratic fitting in order to improve the original estimate of the peak given by inputxmaxandymax. If a single integer number is provided, then it is assumed that search box is a square with sides of length given bypeak_fit_box. If a tuple of two values is provided, then first value indicates the width of the box and the second value indicates the height of the box.'off'orNoneturns off brute-force search of the maximum. Whenpeak_search_boxis'all'then the entireimage_datadata array is searched for maximum and when it is set to'fitbox'then the brute-force search is performed in the same box aspeak_fit_box.Note
This parameter is ignored when both
xmaxandymaxareNonesince in that case the brute-force search for the maximum is performed in the entire input array.- masknumpy.ndarray, optional
A boolean type
ndarrayindicating “good” pixels in image data (True) and “bad” pixels (False). If not provided all pixels inimage_datawill be used for fitting.
- Returns
- coordtuple of float
A pair of coordinates of the peak.