Module: filter.rank

deprecated

class skimage.filter.rank.deprecated(alt_func=None, behavior='warn')

Bases: object

Decorator to mark deprecated functions with warning.

Adapted from <http://wiki.python.org/moin/PythonDecoratorLibrary>.

Parameters:

alt_func : str

If given, tell user what function to use instead.

behavior : {‘warn’, ‘raise’}

Behavior during call to deprecated function: ‘warn’ = warn user that function is deprecated; ‘raise’ = raise error.

__init__(alt_func=None, behavior='warn')
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.bilateral_mean(*args, ...) Deprecated function. Use mean_bilateral instead.
skimage.filter.rank.bilateral_pop(*args, ...) Deprecated function. Use pop_bilateral instead.
skimage.filter.rank.bottomhat(image, selem) Returns greyscale local bottomhat of an image.
skimage.filter.rank.enhance_contrast(image, ...) Enhance an image replacing each pixel by the local maximum if pixel greylevel is closest to maximimum than local minimum OR local minimum otherwise.
skimage.filter.rank.enhance_contrast_percentile(...) Return greyscale local enhance_contrast of an image.
skimage.filter.rank.entropy(image, selem[, ...]) Returns the entropy [R145] computed locally.
skimage.filter.rank.equalize(image, selem[, ...]) Equalize image using local histogram.
skimage.filter.rank.gradient(image, selem[, ...]) Return greyscale local gradient of an image (i.e.
skimage.filter.rank.gradient_percentile(...) Return greyscale local gradient of an image.
skimage.filter.rank.maximum(image, selem[, ...]) Return greyscale local maximum of an image.
skimage.filter.rank.mean(image, selem[, ...]) Return greyscale 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 greyscale local mean of an image.
skimage.filter.rank.meansubtraction(*args, ...) Deprecated function. Use subtract_mean instead.
skimage.filter.rank.median(image, selem[, ...]) Return greyscale local median of an image.
skimage.filter.rank.minimum(image, selem[, ...]) Return greyscale local minimum of an image.
skimage.filter.rank.modal(image, selem[, ...]) Return greyscale local mode of an image.
skimage.filter.rank.morph_contr_enh(*args, ...) Deprecated function. Use enhance_contrast instead.
skimage.filter.rank.noise_filter(image, selem) Returns the noise feature as described in [Hashimoto12]
skimage.filter.rank.otsu(image, selem[, ...]) Returns the Otsu’s threshold value for each pixel.
skimage.filter.rank.percentile(image, selem) Return greyscale local percentile of an image.
skimage.filter.rank.percentile_autolevel(...) Deprecated function. Use autolevel_percentile instead.
skimage.filter.rank.percentile_gradient(...) Deprecated function. Use gradient_percentile instead.
skimage.filter.rank.percentile_mean(*args, ...) Deprecated function. Use mean_percentile instead.
skimage.filter.rank.percentile_mean_subtraction(...) Deprecated function. Use subtract_mean_percentile instead.
skimage.filter.rank.percentile_morph_contr_enh(...) Deprecated function. Use enhance_contrast_percentile instead.
skimage.filter.rank.percentile_pop(*args, ...) Deprecated function. Use pop_percentile instead.
skimage.filter.rank.percentile_threshold(...) Deprecated function. Use threshold_percentile instead.
skimage.filter.rank.pop(image, selem[, out, ...]) Return the number (population) of pixels actually inside the neighborhood.
skimage.filter.rank.pop_bilateral(image, selem) Return the number (population) of pixels actually inside the bilateral neighborhood, i.e.
skimage.filter.rank.pop_percentile(image, selem) Return greyscale local pop of an image.
skimage.filter.rank.subtract_mean(image, selem) Return image subtracted from its local mean.
skimage.filter.rank.subtract_mean_percentile(...) Return greyscale local subtract_mean of an image.
skimage.filter.rank.threshold(image, selem) Return greyscale local threshold of an image.
skimage.filter.rank.threshold_percentile(...) Return greyscale local threshold of an image.
skimage.filter.rank.tophat(image, selem[, ...]) Return greyscale local tophat of an image.

autolevel

skimage.filter.rank.autolevel(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Autolevel image using local histogram.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import autolevel
>>> # Load test image
>>> ima = data.camera()
>>> # Stretch image contrast locally
>>> auto = autolevel(ima, disk(20))

autolevel_percentile

skimage.filter.rank.autolevel_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1)

Return greyscale local autolevel of an image.

Autolevel is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

bilateral_mean

skimage.filter.rank.bilateral_mean(*args, **kwargs)

Deprecated function. Use mean_bilateral instead.

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 structuring element (selem).

Radiometric similarity is defined by the greylevel interval [g-s0, 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. Return greyscale local bilateral_mean of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

s0, s1 : int

Define the [s0, s1] interval around the greyvalue of the center pixel to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import bilateral_mean
>>> # Load test image / cast to uint16
>>> ima = data.camera().astype(np.uint16)
>>> # bilateral filtering of cameraman image using a flat kernel
>>> bilat_ima = bilateral_mean(ima, disk(20), s0=10,s1=10)

bilateral_pop

skimage.filter.rank.bilateral_pop(*args, **kwargs)

Deprecated function. Use pop_bilateral instead.

Return the number (population) of pixels actually inside the bilateral neighborhood, i.e. being inside the structuring element AND having a gray level inside the interval [g-s0, g+s1].

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

s0, s1 : int

Define the [s0, s1] interval around the greyvalue of the center pixel to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> # Local mean
>>> from skimage.morphology import square
>>> import skimage.filter.rank as rank
>>> ima16 = 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.bilateral_pop(ima16, 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)

bottomhat

skimage.filter.rank.bottomhat(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Returns greyscale local bottomhat of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

bottomhat : ndarray (same dtype as input image)

The result of the local bottomhat.

enhance_contrast

skimage.filter.rank.enhance_contrast(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Enhance an image replacing each pixel by the local maximum if pixel greylevel is closest to maximimum than local minimum OR local minimum otherwise.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns :

Output image.

out : ndarray (same dtype as input image)

The result of the local enhance_contrast.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import enhance_contrast
>>> # Load test image
>>> ima = data.camera()
>>> # Local mean
>>> avg = enhance_contrast(ima, disk(20))

enhance_contrast_percentile

skimage.filter.rank.enhance_contrast_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1)

Return greyscale local enhance_contrast of an image.

enhance_contrast is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

entropy

skimage.filter.rank.entropy(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Returns the entropy [R146] computed locally. Entropy is computed using base 2 logarithm i.e. the filter returns the minimum number of bits needed to encode local greylevel distribution.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (double)

Output image.

References

[R146](1, 2) http://en.wikipedia.org/wiki/Entropy_(information_theory)>

Examples

>>> # Local entropy
>>> from skimage import data
>>> from skimage.filter.rank import entropy
>>> from skimage.morphology import disk
>>> a8 = data.camera()
>>> ent8 = entropy(a8, disk(5))

equalize

skimage.filter.rank.equalize(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Equalize image using local histogram.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import equalize
>>> # Load test image
>>> ima = data.camera()
>>> # Local equalization
>>> equ = equalize(ima, disk(20))

gradient

skimage.filter.rank.gradient(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return greyscale local gradient of an image (i.e. local maximum - local minimum).

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

gradient_percentile

skimage.filter.rank.gradient_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1)

Return greyscale local gradient of an image.

gradient is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

maximum

skimage.filter.rank.maximum(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return greyscale local maximum of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

mean

skimage.filter.rank.mean(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return greyscale local mean of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import mean
>>> # Load test image
>>> ima = data.camera()
>>> # Local mean
>>> avg = mean(ima, disk(20))

mean_bilateral

skimage.filter.rank.mean_bilateral(image, selem, out=None, mask=None, shift_x=False, shift_y=False, s0=10, s1=10)

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 structuring element (selem).

Radiometric similarity is defined by the greylevel interval [g-s0, 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. Return greyscale local bilateral_mean of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

s0, s1 : int

Define the [s0, s1] interval around the greyvalue of the center pixel to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import bilateral_mean
>>> # Load test image / cast to uint16
>>> ima = data.camera().astype(np.uint16)
>>> # bilateral filtering of cameraman image using a flat kernel
>>> bilat_ima = bilateral_mean(ima, disk(20), s0=10,s1=10)

mean_percentile

skimage.filter.rank.mean_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1)

Return greyscale local mean of an image.

Mean is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

meansubtraction

skimage.filter.rank.meansubtraction(*args, **kwargs)

Deprecated function. Use subtract_mean instead.

Return image subtracted from its local mean.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

median

skimage.filter.rank.median(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return greyscale local median of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import median
>>> # Load test image
>>> ima = data.camera()
>>> # Local mean
>>> avg = median(ima, disk(20))

minimum

skimage.filter.rank.minimum(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return greyscale local minimum of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

morph_contr_enh

skimage.filter.rank.morph_contr_enh(*args, **kwargs)

Deprecated function. Use enhance_contrast instead.

Enhance an image replacing each pixel by the local maximum if pixel greylevel is closest to maximimum than local minimum OR local minimum otherwise.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns :

Output image.

out : ndarray (same dtype as input image)

The result of the local enhance_contrast.

Examples

>>> from skimage import data
>>> from skimage.morphology import disk
>>> from skimage.filter.rank import enhance_contrast
>>> # Load test image
>>> ima = data.camera()
>>> # Local mean
>>> avg = enhance_contrast(ima, disk(20))

noise_filter

skimage.filter.rank.noise_filter(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Returns the noise feature as described in [Hashimoto12]

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

References

[Hashimoto12](1, 2, 3) N. Hashimoto et al. Referenceless image quality evaluation for whole slide imaging. J Pathol Inform 2012;3:9.

otsu

skimage.filter.rank.otsu(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Returns the Otsu’s threshold value for each pixel.

Parameters:

image : ndarray

Image array (uint8 array).

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

References

[otsu]http://en.wikipedia.org/wiki/Otsu’s_method

Examples

>>> # Local entropy
>>> from skimage import data
>>> from skimage.filter.rank import otsu
>>> from skimage.morphology import disk
>>> # defining a 8-bit test images
>>> a8 = data.camera()
>>> loc_otsu = otsu(a8, disk(5))
>>> thresh_image = a8 >= loc_otsu

percentile

skimage.filter.rank.percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0)

Return greyscale local percentile of an image.

percentile is computed on the given structuring element. Returns the value of the p0 lower percentile of the neighborhood value distribution.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0 : float in [0, ..., 1]

Set the percentile value.

Returns:

out : ndarray (same dtype as input image)

Output image.

percentile_autolevel

skimage.filter.rank.percentile_autolevel(*args, **kwargs)

Deprecated function. Use autolevel_percentile instead.

Return greyscale local autolevel of an image.

Autolevel is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

percentile_gradient

skimage.filter.rank.percentile_gradient(*args, **kwargs)

Deprecated function. Use gradient_percentile instead.

Return greyscale local gradient of an image.

gradient is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

percentile_mean

skimage.filter.rank.percentile_mean(*args, **kwargs)

Deprecated function. Use mean_percentile instead.

Return greyscale local mean of an image.

Mean is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

percentile_mean_subtraction

skimage.filter.rank.percentile_mean_subtraction(*args, **kwargs)

Deprecated function. Use subtract_mean_percentile instead.

Return greyscale local subtract_mean of an image.

subtract_mean is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

percentile_morph_contr_enh

skimage.filter.rank.percentile_morph_contr_enh(*args, **kwargs)

Deprecated function. Use enhance_contrast_percentile instead.

Return greyscale local enhance_contrast of an image.

enhance_contrast is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

percentile_pop

skimage.filter.rank.percentile_pop(*args, **kwargs)

Deprecated function. Use pop_percentile instead.

Return greyscale local pop of an image.

pop is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

percentile_threshold

skimage.filter.rank.percentile_threshold(*args, **kwargs)

Deprecated function. Use threshold_percentile instead.

Return greyscale local threshold of an image.

threshold is computed on the given structuring element. Returns thresholded image such that pixels having a higher value than the the p0 percentile of the neighborhood value distribution are set to 2^nbit-1 (e.g. 255 for 8bit image).

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0 : float in [0, ..., 1]

Set the percentile value.

out : ndarray (same dtype as input image) Output image.

local threshold : ndarray (same dtype as input)

The result of the local threshold.

pop

skimage.filter.rank.pop(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return the number (population) of pixels actually inside the neighborhood.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> # Local mean
>>> from skimage.morphology import square
>>> import skimage.filter.rank as rank
>>> ima = 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(ima, 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)

pop_bilateral

skimage.filter.rank.pop_bilateral(image, selem, out=None, mask=None, shift_x=False, shift_y=False, s0=10, s1=10)

Return the number (population) of pixels actually inside the bilateral neighborhood, i.e. being inside the structuring element AND having a gray level inside the interval [g-s0, g+s1].

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

s0, s1 : int

Define the [s0, s1] interval around the greyvalue of the center pixel to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> # Local mean
>>> from skimage.morphology import square
>>> import skimage.filter.rank as rank
>>> ima16 = 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.bilateral_pop(ima16, 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)

pop_percentile

skimage.filter.rank.pop_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1)

Return greyscale local pop of an image.

pop is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

subtract_mean

skimage.filter.rank.subtract_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return image subtracted from its local mean.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

subtract_mean_percentile

skimage.filter.rank.subtract_mean_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0, p1=1)

Return greyscale local subtract_mean of an image.

subtract_mean is computed on the given structuring element. Only levels between percentiles [p0, p1] are used.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0, p1 : float in [0, ..., 1]

Define the [p0, p1] percentile interval to be considered for computing the value.

Returns:

out : ndarray (same dtype as input image)

Output image.

threshold

skimage.filter.rank.threshold(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return greyscale local threshold of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.

Examples

>>> # Local threshold
>>> from skimage.morphology import square
>>> from skimage.filter.rank import threshold
>>> ima = 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(ima, 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)

threshold_percentile

skimage.filter.rank.threshold_percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=0)

Return greyscale local threshold of an image.

threshold is computed on the given structuring element. Returns thresholded image such that pixels having a higher value than the the p0 percentile of the neighborhood value distribution are set to 2^nbit-1 (e.g. 255 for 8bit image).

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

p0 : float in [0, ..., 1]

Set the percentile value.

out : ndarray (same dtype as input image) Output image.

local threshold : ndarray (same dtype as input)

The result of the local threshold.

tophat

skimage.filter.rank.tophat(image, selem, out=None, mask=None, shift_x=False, shift_y=False)

Return greyscale local tophat of an image.

Parameters:

image : ndarray (uint8, uint16)

Image array.

selem : ndarray

The neighborhood expressed as a 2-D array of 1’s and 0’s.

out : ndarray (same dtype as input)

If None, a new array will be allocated.

mask : ndarray

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y : int

Offset added to the structuring element center point. Shift is bounded to the structuring element sizes (center must be inside the given structuring element).

Returns:

out : ndarray (same dtype as input image)

Output image.