skimage.filter.rank.autolevel(image, selem)  Autolevel image using local histogram. 
skimage.filter.rank.autolevel_percentile(...)  Return greyscale local autolevel of an image. 
skimage.filter.rank.bottomhat(image, selem)  Local bottomhat of an image. 
skimage.filter.rank.enhance_contrast(image, ...)  Enhance contrast of an image. 
skimage.filter.rank.enhance_contrast_percentile(...)  Enhance contrast of an image. 
skimage.filter.rank.entropy(image, selem[, ...])  Local entropy [R194]. 
skimage.filter.rank.equalize(image, selem[, ...])  Equalize image using local histogram. 
skimage.filter.rank.gradient(image, selem[, ...])  Return local gradient of an image (i.e. 
skimage.filter.rank.gradient_percentile(...)  Return local gradient of an image (i.e. 
skimage.filter.rank.maximum(image, selem[, ...])  Return local maximum of an image. 
skimage.filter.rank.mean(image, selem[, ...])  Return local mean of an image. 
skimage.filter.rank.mean_bilateral(image, selem)  Apply a flat kernel bilateral filter. 
skimage.filter.rank.mean_percentile(image, selem)  Return local mean of an image. 
skimage.filter.rank.median(image, selem[, ...])  Return local median of an image. 
skimage.filter.rank.minimum(image, selem[, ...])  Return local minimum of an image. 
skimage.filter.rank.modal(image, selem[, ...])  Return local mode of an image. 
skimage.filter.rank.noise_filter(image, selem)  Noise feature as described in [Hashimoto12]. 
skimage.filter.rank.otsu(image, selem[, ...])  Local Otsu’s threshold value for each pixel. 
skimage.filter.rank.percentile(image, selem)  Return local percentile of an image. 
skimage.filter.rank.pop(image, selem[, out, ...])  Return the local number (population) of pixels. 
skimage.filter.rank.pop_bilateral(image, selem)  Return the local number (population) of pixels. 
skimage.filter.rank.pop_percentile(image, selem)  Return the local number (population) of pixels. 
skimage.filter.rank.subtract_mean(image, selem)  Return image subtracted from its local mean. 
skimage.filter.rank.subtract_mean_percentile(...)  Return image subtracted from its local mean. 
skimage.filter.rank.sum(image, selem[, out, ...])  Return the local sum of pixels. 
skimage.filter.rank.sum_bilateral(image, selem)  Apply a flat kernel bilateral filter. 
skimage.filter.rank.sum_percentile(image, selem)  Return the local sum of pixels. 
skimage.filter.rank.threshold(image, selem)  Local threshold of an image. 
skimage.filter.rank.threshold_percentile(...)  Local threshold of an image. 
skimage.filter.rank.tophat(image, selem[, ...])  Local tophat of an image. 
Autolevel image using local histogram.
This filter locally stretches the histogram of greyvalues to cover the entire range of values from “white” to “black”.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import autolevel
>>> img = data.camera()
>>> auto = autolevel(img, disk(5))
Return greyscale local autolevel of an image.
This filter locally stretches the histogram of greyvalues to cover the entire range of values from “white” to “black”.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0, p1 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Local bottomhat of an image.
This filter computes the morphological closing of the image and then subtracts the result from the original image.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : 2D array
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import bottomhat
>>> img = data.camera()
>>> out = bottomhat(img, disk(5))
Enhance contrast of an image.
This replaces each pixel by the local maximum if the pixel greyvalue is closer to the local maximum than the local minimum. Otherwise it is replaced by the local minimum.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
Returns :
out : 2D array (same dtype as input image)


Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import enhance_contrast
>>> img = data.camera()
>>> out = enhance_contrast(img, disk(5))
Enhance contrast of an image.
This replaces each pixel by the local maximum if the pixel greyvalue is closer to the local maximum than the local minimum. Otherwise it is replaced by the local minimum.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0, p1 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Local entropy [R195].
The entropy is computed using base 2 logarithm i.e. the filter returns the minimum number of bits needed to encode the local greylevel distribution.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : ndarray (double)

References
[R195]  (1, 2) http://en.wikipedia.org/wiki/Entropy_(information_theory) 
Examples
>>> from skimage import data
>>> from skimage.filter.rank import entropy
>>> from skimage.morphology import disk
>>> img = data.camera()
>>> ent = entropy(img, disk(5))
Equalize image using local histogram.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import equalize
>>> img = data.camera()
>>> equ = equalize(img, disk(5))
Return local gradient of an image (i.e. local maximum  local minimum).
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import gradient
>>> img = data.camera()
>>> out = gradient(img, disk(5))
Return local gradient of an image (i.e. local maximum  local minimum).
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0, p1 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Return local maximum of an image.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

See also
Notes
The lower algorithm complexity makes the skimage.filter.rank.maximum more efficient for larger images and structuring elements.
Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import maximum
>>> img = data.camera()
>>> out = maximum(img, disk(5))
Return local mean of an image.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import mean
>>> img = data.camera()
>>> avg = mean(img, disk(5))
Apply a flat kernel bilateral filter.
This is an edgepreserving 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 structuring element.
Radiometric similarity is defined by the greylevel interval [gs0, g+s1] where g is the current pixel greylevel.
Only pixels belonging to the structuring element and having a greylevel inside this interval are averaged.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
s0, s1 : int


Returns:  out : 2D array (same dtype as input image)

See also
Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import mean_bilateral
>>> img = data.camera().astype(np.uint16)
>>> bilat_img = mean_bilateral(img, disk(20), s0=10,s1=10)
Return local mean of an image.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0, p1 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Return local median of an image.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import median
>>> img = data.camera()
>>> med = median(img, disk(5))
Return local minimum of an image.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

See also
Notes
The lower algorithm complexity makes the skimage.filter.rank.minimum more efficient for larger images and structuring elements.
Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import minimum
>>> img = data.camera()
>>> out = minimum(img, disk(5))
Return local mode of an image.
The mode is the value that appears most often in the local histogram.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import modal
>>> img = data.camera()
>>> out = modal(img, disk(5))
Noise feature as described in [Hashimoto12].
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

References
[Hashimoto12]  (1, 2, 3) N. Hashimoto et al. Referenceless image quality evaluation for whole slide imaging. J Pathol Inform 2012;3:9. 
Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import noise_filter
>>> img = data.camera()
>>> out = noise_filter(img, disk(5))
Local Otsu’s threshold value for each pixel.
Parameters:  image : ndarray
selem : 2D array
out : ndarray
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

References
[otsu]  http://en.wikipedia.org/wiki/Otsu’s_method 
Examples
>>> from skimage import data
>>> from skimage.filter.rank import otsu
>>> from skimage.morphology import disk
>>> img = data.camera()
>>> local_otsu = otsu(img, disk(5))
>>> thresh_image = img >= local_otsu
Return local percentile of an image.
Returns the value of the p0 lower percentile of the local greyvalue distribution.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Return the local number (population) of pixels.
The number of pixels is defined as the number of pixels which are included in the structuring element and the mask.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage.morphology import square
>>> import skimage.filter.rank as rank
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 0, 0, 0, 0]], dtype=np.uint8)
>>> rank.pop(img, square(3))
array([[4, 6, 6, 6, 4],
[6, 9, 9, 9, 6],
[6, 9, 9, 9, 6],
[6, 9, 9, 9, 6],
[4, 6, 6, 6, 4]], dtype=uint8)
Return the local number (population) of pixels.
The number of pixels is defined as the number of pixels which are included in the structuring element and the mask. Additionally the must have a greylevel inside the interval [gs0, g+s1] where g is the greyvalue of the center pixel.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
s0, s1 : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage.morphology import square
>>> import skimage.filter.rank as rank
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 0, 0, 0, 0]], dtype=np.uint16)
>>> rank.pop_bilateral(img, square(3), s0=10, s1=10)
array([[3, 4, 3, 4, 3],
[4, 4, 6, 4, 4],
[3, 6, 9, 6, 3],
[4, 4, 6, 4, 4],
[3, 4, 3, 4, 3]], dtype=uint16)
Return the local number (population) of pixels.
The number of pixels is defined as the number of pixels which are included in the structuring element and the mask.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0, p1 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Return image subtracted from its local mean.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import subtract_mean
>>> img = data.camera()
>>> out = subtract_mean(img, disk(5))
Return image subtracted from its local mean.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0, p1 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Return the local sum of pixels.
Note that the sum may overflow depending on the data type of the input array.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage.morphology import square
>>> import skimage.filter.rank as rank
>>> img = np.array([[0, 0, 0, 0, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 0, 0, 0, 0]], dtype=np.uint8)
>>> rank.sum(img, square(3))
array([[1, 2, 3, 2, 1],
[2, 4, 6, 4, 2],
[3, 6, 9, 6, 3],
[2, 4, 6, 4, 2],
[1, 2, 3, 2, 1]], dtype=uint8)
Apply a flat kernel bilateral filter.
This is an edgepreserving 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 structuring element (selem).
Radiometric similarity is defined by the greylevel interval [gs0, g+s1] where g is the current pixel greylevel.
Only pixels belonging to the structuring element AND having a greylevel inside this interval are summed.
Note that the sum may overflow depending on the data type of the input array.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
s0, s1 : int


Returns:  out : 2D array (same dtype as input image)

See also
Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import sum_bilateral
>>> img = data.camera().astype(np.uint16)
>>> bilat_img = sum_bilateral(img, disk(10), s0=10, s1=10)
Return the local sum of pixels.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Note that the sum may overflow depending on the data type of the input array.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0, p1 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Local threshold of an image.
The resulting binary mask is True if the greyvalue of the center pixel is greater than the local mean.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage.morphology import square
>>> from skimage.filter.rank import threshold
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 1, 1, 1, 0],
... [0, 0, 0, 0, 0]], dtype=np.uint8)
>>> threshold(img, square(3))
array([[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 0, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0]], dtype=uint8)
Local threshold of an image.
The resulting binary mask is True if the greyvalue of the center pixel is greater than the local mean.
Only greyvalues between percentiles [p0, p1] are considered in the filter.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int
p0 : float in [0, ..., 1]


Returns:  out : 2D array (same dtype as input image)

Local tophat of an image.
This filter computes the morphological opening of the image and then subtracts the result from the original image.
Parameters:  image : 2D array (uint8, uint16)
selem : 2D array
out : 2D array (same dtype as input)
mask : ndarray
shift_x, shift_y : int


Returns:  out : 2D array (same dtype as input image)

Examples
>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import tophat
>>> img = data.camera()
>>> out = tophat(img, disk(5))