pybaselines.Baseline2D.tophat

Baseline2D.tophat(data, half_window=None, window_kwargs=None, **kwargs)[source]

Estimates the baseline using a top-hat transformation (morphological opening).

Parameters:
dataarray_like, shape (M, N)

The y-values of the measured data.

half_windowint or sequence[int, int], optional

The half-window used for the rows and columns, respectively, for the morphology functions. If a single value is given, rows and columns will use the same value. Default is None, which will optimize the half-window size using optimize_window() and window_kwargs.

window_kwargsdict, optional

A dictionary of keyword arguments to pass to optimize_window() for estimating the half window if half_window is None. Default is None.

**kwargs

Deprecated since version 1.2.0: Passing additional keyword arguments is deprecated and will be removed in version 1.4.0. Pass keyword arguments using window_kwargs.

Returns:
baselinenumpy.ndarray, shape (M, N)

The calculated baseline.

dict

A dictionary with the following items:

  • 'half_window': np.ndarray[int, int]

    The half windows used for the morphological calculations.

Notes

The actual top-hat transformation is defined as data - opening(data), where opening is the morphological opening operation. This function, however, returns opening(data), since that is technically the baseline defined by the operation.

References

Perez-Pueyo, R., et al. Morphology-Based Automated Baseline Removal for Raman Spectra of Artistic Pigments. Applied Spectroscopy, 2010, 64, 595-600.