import numpy as np
import scipy.ndimage as ndi
from skimage.morphology import square
img = np.random.uniform(size=(5, 5))
img = (img > 0.5).astype(np.float)
sem = square(3)/3**2 # Don't forget to normalize
out = ndi.convolve(img, sem, mode='wrap')
print(img)
print(sem)
print(out)
[[ 1. 0. 0. 1. 0.]
[ 1. 0. 0. 0. 0.]
[ 0. 0. 1. 1. 0.]
[ 0. 0. 0. 0. 1.]
[ 1. 0. 1. 0. 0.]]
[[ 0.11111111 0.11111111 0.11111111]
[ 0.11111111 0.11111111 0.11111111]
[ 0.11111111 0.11111111 0.11111111]]
[[ 0.33333333 0.44444444 0.22222222 0.22222222 0.44444444]
[ 0.22222222 0.33333333 0.33333333 0.33333333 0.44444444]
[ 0.22222222 0.22222222 0.22222222 0.33333333 0.33333333]
[ 0.22222222 0.33333333 0.33333333 0.44444444 0.33333333]
[ 0.33333333 0.33333333 0.22222222 0.33333333 0.44444444]]
--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
To post to this group, send email to scikit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/1b36234e-79ed-4eec-9c4a-ea1b659069f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.