Skip to content

Instantly share code, notes, and snippets.

@sgillies
Created February 10, 2014 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgillies/8924974 to your computer and use it in GitHub Desktop.
Save sgillies/8924974 to your computer and use it in GitHub Desktop.
>>> import numpy
>>> from scipy.ndimage.morphology import grey_dilation
>>> a = numpy.zeros((7, 7))
>>> a[3,3] = 1
>>> a
array([[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 1., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.]])
>>> b = grey_dilation(a, size=3)
>>> b
array([[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 1., 1., 1., 0., 0.],
[ 0., 0., 1., 1., 1., 0., 0.],
[ 0., 0., 1., 1., 1., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0.]])
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment