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:
- img
ndarrayofshape(H,W)or(H,W,C) Image (or stack of images along the last axis).
- window_size
int, default=3 Side of the square neighborhood \(N_k\); the center pixel is not counted. Borders are reflected.
- kernel
ndarrayofshape(window_size,window_size),optional Weights of the neighbors instead of ones (the center entry is ignored and set to zero).
- img
- Returns:
- out
ndarray,sameshapeasimg
- out
Examples
>>> import numpy as np >>> from fuzzyclust.image import neighborhood_sum >>> neighborhood_sum(np.ones((3, 3)))[1, 1] np.float64(8.0)