skimage.filters.rank
Auto-level image using local histogram. | |
Return grayscale local autolevel of an image. | |
Auto-level image using local histogram. | |
Return grayscale local autolevel of an image. | |
Enhance contrast of an image. |
Enhance contrast of an image. |
Local entropy. |
Equalize image using local histogram. |
Return local geometric mean of an image. |
Return local gradient of an image (i.e. local maximum - local minimum). |
Return local gradient of an image (i.e. local maximum - local minimum). |
Assign to each pixel the most common value within its neighborhood. |
Return local maximum of an image. |
Return local mean of an image. |
Apply a flat kernel bilateral filter. |
Return local mean of an image. |
Return local median of an image. |
Return local minimum of an image. |
Return local mode of an image. |
Noise feature. |
Local Otsu's threshold value for each pixel. |
Return local percentile of an image. |
Return the local number (population) of pixels. |
Return the local number (population) of pixels. |
Return the local number (population) of pixels. |
Return image subtracted from its local mean. |
Return image subtracted from its local mean. |
Return the local sum of pixels. |
Apply a flat kernel bilateral filter. |
Return the local sum of pixels. |
Local threshold of an image. |
Local threshold of an image. |
Normalized sliding window histogram |
Auto-level image using local histogram.
This filter locally stretches the histogram of gray values to cover the entire range of values from “white” to “black”.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import autolevel
>>> import numpy as np
>>> img = data.camera()
>>>
Return grayscale local autolevel of an image.
This filter locally stretches the histogram of grayvalues to cover the entire range of values from “white” to “black”.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Define the [p0, p1] percentile interval to be considered for computing the value.
imageOutput image.
Enhance contrast of an image.
This replaces each pixel by the local maximum if the pixel gray value is closer to the local maximum than the local minimum. Otherwise it is replaced by the local minimum.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import enhance_contrast
>>> import numpy as np
>>> img = data.camera()
>>>
Enhance contrast of an image.
This replaces each pixel by the local maximum if the pixel grayvalue is closer to the local maximum than the local minimum. Otherwise it is replaced by the local minimum.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Define the [p0, p1] percentile interval to be considered for computing the value.
imageOutput image.
Local entropy.
The entropy is computed using base 2 logarithm i.e. the filter returns the minimum number of bits needed to encode the local gray level distribution.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Output image.
>>> from skimage import data
>>> from skimage.filters.rank import entropy
>>> from skimage.morphology import disk, ball
>>> import numpy as np
>>> img = data.camera()
Equalize image using local histogram.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import equalize
>>> import numpy as np
>>> img = data.camera()
>>>
Return local geometric mean of an image.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
Gonzalez, R. C. and Woods, R. E. “Digital Image Processing (3rd Edition).” Prentice-Hall Inc, 2006.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import mean
>>> import numpy as np
>>> img = data.camera()
Return local gradient of an image (i.e. local maximum - local minimum).
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import gradient
>>> import numpy as np
>>> img = data.camera()
>>>
Return local gradient of an image (i.e. local maximum - local minimum).
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Define the [p0, p1] percentile interval to be considered for computing the value.
imageOutput image.
Assign to each pixel the most common value within its neighborhood.
Image array (uint8, uint16 array).
The neighborhood expressed as a 2-D array of 1’s and 0’s.
If None, a new array will be allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.filters.rank import majority
>>> from skimage.morphology import disk, ball
>>> import numpy as np
>>> img = data.camera()
>>>
Return local maximum of an image.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
The lower algorithm complexity makes skimage.filters.rank.maximum
more efficient for larger images and footprints.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import maximum
>>> import numpy as np
>>> img = data.camera()
Return local mean of an image.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import mean
>>> import numpy as np
>>> img = data.camera()
>>>
Apply a flat kernel bilateral filter.
This is an edge-preserving and noise reducing denoising filter. It averages pixels based on their spatial closeness and radiometric similarity.
Spatial closeness is measured by considering only the local pixel neighborhood given by a footprint (structuring element).
Radiometric similarity is defined by the graylevel interval [g-s0, g+s1] where g is the current pixel graylevel.
Only pixels belonging to the footprint and having a graylevel inside this interval are averaged.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
>>> import numpy as np
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filters.rank import mean_bilateral
>>> img = data.camera().astype
Return local mean of an image.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Define the [p0, p1] percentile interval to be considered for computing the value.
imageOutput image.
Return local median of an image.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s. If None, a full square of size 3 is used.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import median
>>> import numpy as np
>>> img = data.camera()
>>>
Return local minimum of an image.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
The lower algorithm complexity makes skimage.filters.rank.minimum more
efficient for larger images and footprints.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import minimum
>>> import numpy as np
>>> img = data.camera()
Return local mode of an image.
The mode is the value that appears most often in the local histogram.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import modal
>>> import numpy as np
>>> img = data.camera()
>>>
Noise feature.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
N. Hashimoto et al. Referenceless image quality evaluation for whole slide imaging. J Pathol Inform 2012;3:9.
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import noise_filter
>>> import numpy as np
>>> img = data.camera()
Local Otsu’s threshold value for each pixel.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage import data
>>> from skimage.filters.rank import otsu
>>> from skimage.morphology import disk, ball
>>> import numpy as np
>>> img = data.camera()
Return local percentile of an image.
Returns the value of the p0 lower percentile of the local grayvalue distribution.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Set the percentile value.
imageOutput image.
Return the local number (population) of pixels.
The number of pixels is defined as the number of pixels which are included in the footprint and the mask.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage.morphology import footprint_rectangle # Need to add 3D example
>>> import skimage.filters.rank as rank
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
... [
Return the local number (population) of pixels.
The number of pixels is defined as the number of pixels which are included in the footprint and the mask. Additionally pixels must have a graylevel inside the interval [g-s0, g+s1] where g is the grayvalue of the center pixel.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Define the [s0, s1] interval around the grayvalue of the center pixel to be considered for computing the value.
imageOutput image.
>>> import numpy as np
>>> from skimage.morphology import footprint_rectangle
>>> import skimage.filters.rank as rank
>>> img = 255 * np.array([[0, 0, 0, 0
Return the local number (population) of pixels.
The number of pixels is defined as the number of pixels which are included in the footprint and the mask.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Define the [p0, p1] percentile interval to be considered for computing the value.
imageOutput image.
Return image subtracted from its local mean.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
Subtracting the mean value may introduce underflow. To compensate
this potential underflow, the obtained difference is downscaled by
a factor of 2 and shifted by n_bins / 2 - 1, the median value of
the local histogram (n_bins = max(3, image.max()) +1 for 16-bits
images and 256 otherwise).
>>> from skimage import data
>>> from skimage.morphology import disk, ball
>>> from skimage.filters.rank import subtract_mean
>>> import numpy as np
>>> img = data.camera()
Return image subtracted from its local mean.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
Return the local sum of pixels.
Note that the sum may overflow depending on the data type of the input array.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage.morphology import footprint_rectangle # Need to add 3D example
>>> import skimage.filters.rank as rank # Cube seems to fail but
>>> img = np.array([[0, 0, 0, 0, 0], # Ball can pass
...
Apply a flat kernel bilateral filter.
This is an edge-preserving and noise reducing denoising filter. It averages pixels based on their spatial closeness and radiometric similarity.
Spatial closeness is measured by considering only the local pixel neighborhood given by a footprint (structuring element).
Radiometric similarity is defined by the graylevel interval [g-s0, g+s1] where g is the current pixel graylevel.
Only pixels belonging to the footprint AND having a graylevel inside this interval are summed.
Note that the sum may overflow depending on the data type of the input array.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
>>> import numpy as np
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filters.rank import sum_bilateral
>>> img = data.camera().astype
Return the local sum of pixels.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Note that the sum may overflow depending on the data type of the input array.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
Local threshold of an image.
The resulting binary mask is True if the gray value of the center pixel is greater than the local mean.
Input image.
The neighborhood expressed as an ndarray of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
imageOutput image.
>>> from skimage.morphology import footprint_rectangle # Need to add 3D example
>>> from skimage.filters.rank import threshold
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
... [
Local threshold of an image.
The resulting binary mask is True if the grayvalue of the center pixel is greater than the local mean.
Only grayvalues between percentiles [p0, p1] are considered in the filter.
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
imageIf None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
Set the percentile value.
imageOutput image.
Normalized sliding window histogram
Input image.
The neighborhood expressed as a 2-D array of 1’s and 0’s.
If None, a new array is allocated.
Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).
Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).
The number of histogram bins. Will default to image.max() + 1
if None is passed.
Array of dimensions (H,W,N), where (H,W) are the dimensions of the
input image and N is n_bins or image.max() + 1 if no value is
provided as a parameter. Effectively, each pixel is a N-D feature
vector that is the histogram. The sum of the elements in the feature
vector will be 1, unless no pixels in the window were covered by both
footprint and mask, in which case all elements will be 0.
>>> from skimage import data
>>> from skimage.filters.rank import windowed_histogram
>>> from skimage.morphology import disk, ball
>>> import numpy as np
>>> img = data.camera()
Define the [s0, s1] interval around the grayvalue of the center pixel to be considered for computing the value.
imageOutput image.
Define the [p0, p1] percentile interval to be considered for computing the value.
Define the [s0, s1] interval around the grayvalue of the center pixel to be considered for computing the value.
imageOutput image.
Define the [p0, p1] percentile interval to be considered for computing the value.