Guest User

Untitled

a guest
Dec 13th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sun Dec 10 13:39:28 2017
  4.  
  5. @author: oznur
  6. """
  7.  
  8. import cv2
  9. from skimage import color
  10. import matplotlib.pyplot as plt
  11. from skimage.morphology import skeletonize
  12.  
  13. image = cv2.imread('horse.png')
  14. gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  15. image=color.rgb2gray(image)
  16.  
  17. skeleton =skeletonize(image)
  18.  
  19. fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4),
  20. sharex=True, sharey=True,
  21. subplot_kw={'adjustable': 'box-forced'})
  22.  
  23. ax1,ax2=axes.ravel()
  24.  
  25.  
  26. ax1.imshow(image, cmap=plt.cm.gray)
  27. ax1.axis('off')
  28. ax1.set_title('original', fontsize=20)
  29.  
  30. ax2.imshow(skeleton, cmap=plt.cm.gray)
  31. ax2.axis('off')
  32. ax2.set_title('skeleton', fontsize=20)
  33.  
  34. fig.tight_layout()
  35. plt.show()
Add Comment
Please, Sign In to add comment