Skip to content

Instantly share code, notes, and snippets.

@npyoung
Created October 1, 2016 23:37
Show Gist options
  • Save npyoung/01e0b173af9ab2ff3babb34abb53672f to your computer and use it in GitHub Desktop.
Save npyoung/01e0b173af9ab2ff3babb34abb53672f to your computer and use it in GitHub Desktop.
Visual demonstration of what the disk structuring element in scikit-image is and how it scales.
import numpy as np
import matplotlib.pyplot as plt
from skimage.morphology import disk
N = 5
fig, axes = plt.subplots(1, N, figsize=(16, 3))
for n, ax in enumerate(axes):
np1 = n + 1
ax.imshow(np.pad(disk(np1), N-n, 'constant'), interpolation='nearest')
c = plt.Circle((np1 + N - n, np1 + N - n), radius=np1, fill=False, lw=4, color='b')
ax.add_artist(c)
ax.set_xlim(0, 2 * N + 2)
ax.set_ylim(0, 2 * N + 2)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment