ptypy.utils.scripts.remove_hot_pixels#
- ptypy.utils.scripts.remove_hot_pixels(data, size=3, tolerance=3, ignore_edges=False)#
Replaces outlier data points with the median of the surrounding data points.
Removes outlier data points of a 2D numpy array and replaces them with the median of the surrounding data points. Original code (see at the end of function) had been published by DanHickstein on stackoverflow.com under CC BY-SA license.
- Parameters:
data (2d np.array) – Input 2D numpy array to be corrected.
size (int) – Size of the window on which the median filter will be applied around every data point.
tolerance (int) – Tolerance multiplied with the standard deviation of the data array subtracted by the blurred array (difference array) yields the threshold for cutoff.
ignore_edges (bool) – If True, edges of the array are ignored, which speeds up the code.
- Returns:
out – Returns a 2d np.array where outlier data points have been replaced with the median of the surrounding data points and a list containing the coordinates of the outlier data points.
- Return type:
2d array, list