fuzzyclust.image.neighborhood_sum#

fuzzyclust.image.neighborhood_sum(img, window_size=3, kernel=None)[source]#

Sum of an image over the neighbors of every pixel, \(\sum_{r\in N_k} y_r\) (center excluded).

Parameters:
imgndarray of shape (H, W) or (H, W, C)

Image (or stack of images along the last axis).

window_sizeint, default=3

Side of the square neighborhood \(N_k\); the center pixel is not counted. Borders are reflected.

kernelndarray of shape (window_size, window_size), optional

Weights of the neighbors instead of ones (the center entry is ignored and set to zero).

Returns:
outndarray, same shape as img

Examples

>>> import numpy as np
>>> from fuzzyclust.image import neighborhood_sum
>>> neighborhood_sum(np.ones((3, 3)))[1, 1]
np.float64(8.0)