Module: filter.rank

skimage.filter.rank.autolevel Autolevel image using local histogram.
skimage.filter.rank.bilateral_mean Apply a flat kernel bilateral filter.
skimage.filter.rank.bilateral_pop Return the number (population) of pixels actually inside the bilateral neighborhood, i.e.
skimage.filter.rank.bottomhat Returns greyscale local bottomhat of an image.
skimage.filter.rank.entropy Returns the entropy [wiki_entropy] computed locally.
skimage.filter.rank.equalize Equalize image using local histogram.
skimage.filter.rank.gradient Return greyscale local gradient of an image (i.e.
skimage.filter.rank.maximum Return greyscale local maximum of an image.
skimage.filter.rank.mean Return greyscale local mean of an image.
skimage.filter.rank.meansubstraction Return image substracted from its local mean.
skimage.filter.rank.median Return greyscale local median of an image.
skimage.filter.rank.minimum Return greyscale local minimum of an image.
skimage.filter.rank.modal Return greyscale local mode of an image.
skimage.filter.rank.morph_contr_enh Enhance an image replacing each pixel by the local maximum if pixel
skimage.filter.rank.noise_filter Returns the noise feature as described in [Hashimoto12]
skimage.filter.rank.otsu Returns the Otsu’s threshold value for each pixel.
skimage.filter.rank.percentile Return greyscale local percentile of an image.
skimage.filter.rank.percentile_autolevel Return greyscale local autolevel of an image.
skimage.filter.rank.percentile_gradient Return greyscale local percentile_gradient of an image.
skimage.filter.rank.percentile_mean Return greyscale local mean of an image.
skimage.filter.rank.percentile_mean_substraction Return greyscale local mean_substraction of an image.
skimage.filter.rank.percentile_morph_contr_enh Return greyscale local morph_contr_enh of an image.
skimage.filter.rank.percentile_pop Return greyscale local pop of an image.
skimage.filter.rank.percentile_threshold Return greyscale local threshold of an image.
skimage.filter.rank.pop Return the number (population) of pixels actually inside the neighborhood.
skimage.filter.rank.threshold Return greyscale local threshold of an image.
skimage.filter.rank.tophat Return greyscale local tophat of an image.

autolevel

skimage.filter.rank.autolevel()

Autolevel image using local histogram.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The result of the local autolevel.

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))

bilateral_mean

skimage.filter.rank.bilateral_mean()

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

Image array (uint16). As the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095

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 (uint8)

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 to be considered for computing the value.

Returns :

out : uint16 array

The result of the local bilateral mean.

Notes

  • input image are 16-bit only

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()

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

Image array (uint16). As the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095

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 (uint8)

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 to be considered for computing the value.

Returns :

out : uint16 array

the local number of pixels inside the bilateral neighborhood

Notes

  • input image are 16-bit only

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()

Returns greyscale local bottomhat of an image.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local bottomhat : uint8 array or uint16 array depending on input image

The result of the local bottomhat.

entropy

skimage.filter.rank.entropy()

Returns the entropy [wiki_entropy] 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

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

entropy x10 (uint8 images) and entropy x1000 (uint16 images)

References

[wiki_entropy](1, 2, 3) 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
>>> # defining a 8- and a 16-bit test images
>>> a8 = data.camera()
>>> a16 = data.camera().astype(np.uint16) * 4
>>> # pixel values contain 10x the local entropy
>>> ent8 = entropy(a8, disk(5))
>>> # pixel values contain 1000x the local entropy
>>> ent16 = entropy(a16, disk(5))

equalize

skimage.filter.rank.equalize()

Equalize image using local histogram.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The result of the local equalize.

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()

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

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The local gradient.

maximum

skimage.filter.rank.maximum()

Return greyscale local maximum of an image.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The local maximum.

mean

skimage.filter.rank.mean()

Return greyscale local mean of an image.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The local mean.

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))

meansubstraction

skimage.filter.rank.meansubstraction()

Return image substracted from its local mean.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The result of the local meansubstraction.

median

skimage.filter.rank.median()

Return greyscale local median of an image.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The local median.

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()

Return greyscale local minimum of an image.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The local minimum.

morph_contr_enh

skimage.filter.rank.morph_contr_enh()

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

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The result of the local morph_contr_enh.

Examples

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

noise_filter

skimage.filter.rank.noise_filter()

Returns the noise feature as described in [Hashimoto12]

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The image noise.

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()

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 (uint8)

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 : uint8 array

Otsu’s threshold values

Notes

  • input image are 8-bit only

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()

Return greyscale local percentile of an image.

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

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local percentile : uint8 array or uint16

The result of the local percentile.

percentile_autolevel

skimage.filter.rank.percentile_autolevel()

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

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local autolevel : uint8 array or uint16

The result of the local autolevel.

percentile_gradient

skimage.filter.rank.percentile_gradient()

Return greyscale local percentile_gradient of an image.

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

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local percentile_gradient : uint8 array or uint16

The result of the local percentile_gradient.

percentile_mean

skimage.filter.rank.percentile_mean()

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

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local mean : uint8 array or uint16

The result of the local mean.

percentile_mean_substraction

skimage.filter.rank.percentile_mean_substraction()

Return greyscale local mean_substraction of an image.

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

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local mean_substraction : uint8 array or uint16

The result of the local mean_substraction.

percentile_morph_contr_enh

skimage.filter.rank.percentile_morph_contr_enh()

Return greyscale local morph_contr_enh of an image.

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

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local morph_contr_enh : uint8 array or uint16

The result of the local morph_contr_enh.

percentile_pop

skimage.filter.rank.percentile_pop()

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

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local pop : uint8 array or uint16

The result of the local pop.

percentile_threshold

skimage.filter.rank.percentile_threshold()

Return greyscale local threshold of an image.

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

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, as the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 :

local threshold : uint8 array or uint16

The result of the local threshold.

pop

skimage.filter.rank.pop()

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

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The number of pixels belonging to the neighborhood.

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)

threshold

skimage.filter.rank.threshold()

Return greyscale local threshold of an image.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The result of the local threshold.

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)

tophat

skimage.filter.rank.tophat()

Return greyscale local tophat of an image.

Parameters :

image : ndarray

Image array (uint8 array or uint16). If image is uint16, the algorithm uses max. 12bit histogram, an exception will be raised if image has a value > 4095.

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 (uint8)

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 : uint8 array or uint16 array (same as input image)

The image tophat.