Operasi Morfologi

 Contoh1:

[in]

from skimage.morphology import skeletonize

from skimage import data

import matplotlib.pyplot as plt

from skimage.util import invert

 

# Invert the horse image

image = invert(data.horse())

 

# perform skeletonization

skeleton = skeletonize(image)

 

# display results

fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4),

                         sharex=True, sharey=True)

 

ax = axes.ravel()

 

ax[0].imshow(image, cmap=plt.cm.gray)

ax[0].axis('off')

ax[0].set_title('original', fontsize=20)

 

ax[1].imshow(skeleton, cmap=plt.cm.gray)

ax[1].axis('off')

ax[1].set_title('skeleton', fontsize=20)

 

fig.tight_layout()

plt.show()




Contoh2:

[in]

import matplotlib.pyplot as plt

 

from skimage.morphology import convex_hull_image

from skimage import data, img_as_float

from skimage.util import invert

 

# The original image is inverted as the object must be white.

image = invert(data.horse())

 

chull = convex_hull_image(image)

 

fig, axes = plt.subplots(1, 2, figsize=(8, 4))

ax = axes.ravel()

 

ax[0].set_title('Original picture')

ax[0].imshow(image, cmap=plt.cm.gray)

ax[0].set_axis_off()

 

ax[1].set_title('Transformed picture')

ax[1].imshow(chull, cmap=plt.cm.gray)

ax[1].set_axis_off()

 

plt.tight_layout()

plt.show()









Share on :

0 Response to "Operasi Morfologi"

Posting Komentar