skimage2.filters.rank.windowed_histogram#

skimage2.filters.rank.windowed_histogram(image, footprint, out=None, mask=None, shift_x=0, shift_y=0, n_bins=None)[source]#

Compute normalized sliding window histogram.

Parameters:
imagendarray of shape (H, W) and dtype (int or float)

Input image.

footprintndarray of dtype (int or float)

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

outndarray of shape (H, W, N) and dtype (int or float), optional

If None, a new array is allocated.

maskndarray of dtype (int or float), optional

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_yint, optional

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

n_binsint or None

The number of histogram bins. Defaults to image.max() + 1 if None is passed.

Returns:
outndarray of shape (H, W, N) and dtype float

N is n_bins or image.max() + 1 if no value is passed to n_bins. Effectively, each pixel is a N-D feature vector that is the histogram. The sum of the elements in the feature vector is 1, unless no pixels in the window were covered by both footprint and mask, in which case all elements are 0.

Examples

>>> from _skimage2 import data
>>> from _skimage2.filters.rank import windowed_histogram
>>> from _skimage2.morphology import disk, ball
>>> import numpy as np
>>> img = data.camera()
>>> rng = np.random.default_rng()
>>> volume = rng.integers(0, 255, size=(10,10,10), dtype=np.uint8)
>>> hist_img = windowed_histogram(img, disk(5))