nanshe.imp.filters.noise module¶
The noise
module provides support for handling noise in images.
Overview¶
Provides a way of estimating noise based on what falls out of some multiple of the standard deviation and generate a mask that excludes the noise or the non-noise.
API¶
-
nanshe.imp.filters.noise.
estimate_noise
(*args, **kwargs)[source]¶ Estimates the noise in the given array.
Using the array finds what the standard deviation is of some values in the array, which are within the standard deviation of the whole array times the significance threshold.
Parameters: - input_array (numpy.ndarray) – the array to estimate noise of.
- significance_threshold (float) – the number of standard deviations (of the whole array), below which must be noise.
Returns: - The standard deviation of the
noise.
Return type: noise(float)
Examples
>>> estimate_noise(numpy.eye(2)) 0.5
>>> estimate_noise(numpy.eye(2), 3) 0.5
>>> round(float(estimate_noise(numpy.eye(3), 3)), 3) 0.471
>>> numpy.random.seed(10) >>> round(float(estimate_noise(numpy.random.random((2000,2000)), 1)), 3) 0.167
>>> numpy.random.seed(10) >>> round(float(estimate_noise(numpy.random.random((2000,2000)), 2)), 3) 0.289
>>> numpy.random.seed(10) >>> round(float(estimate_noise(numpy.random.random((2000,2000)), 3)), 3) 0.289
-
nanshe.imp.filters.noise.
noise_mask
(*args, **kwargs)[source]¶ Using estimate_noise, creates a mask that selects the noise and suppresses non-noise.
Parameters: - input_array (numpy.ndarray) – the array to use for generating the noise mask.
- significance_threshold (float) – the number of standard deviations (of the whole array), below which must be noise.
- noise_threshold (float) – the estimated noise times this value determines the max value to consider as noise (to zero).
Returns: - a numpy array with noise
zeroed.
Return type: result(numpy.ndarray)
Examples
>>> noise_mask(numpy.eye(2), 6.0, 0.5) array([[ True, True], [ True, True]], dtype=bool)
>>> noise_mask(numpy.eye(2), 1.0, 0.5) array([[False, False], [False, False]], dtype=bool)
>>> noise_mask(numpy.eye(3), 2.0, 0.47140452079103173) array([[ True, True, True], [ True, True, True], [ True, True, True]], dtype=bool)
>>> noise_mask(numpy.eye(3), 1.0, 0.47140452079103173) array([[False, True, True], [ True, False, True], [ True, True, False]], dtype=bool)
-
nanshe.imp.filters.noise.
significant_mask
(*args, **kwargs)[source]¶ Using estimate_noise, creates a mask that selects the non-noise and suppresses noise.
Parameters: - input_array (numpy.ndarray) – the array, which needs noise removed.
- noise_threshold (float) – the estimated noise times this value determines the max value to consider as noise (to zero).
- in_place (bool) – whether to modify input_array directly or to return a copy instead.
Returns: a numpy array with noise zeroed.
Return type: result(numpy.ndarray)
Examples
>>> significant_mask(numpy.eye(2), 6.0) array([[False, False], [False, False]], dtype=bool)
>>> significant_mask(numpy.eye(2), 6.0, 0.5) array([[False, False], [False, False]], dtype=bool)
>>> significant_mask(numpy.eye(2), 1.0, 0.5) array([[ True, True], [ True, True]], dtype=bool)
>>> significant_mask(numpy.eye(3), 2.0, 0.47140452079103173) array([[False, False, False], [False, False, False], [False, False, False]], dtype=bool)
>>> significant_mask(numpy.eye(3), 1.0, 0.47140452079103173) array([[ True, False, False], [False, True, False], [False, False, True]], dtype=bool)