Guest User

Untitled

a guest
Dec 11th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3. from matplotlib import pyplot as plt
  4.  
  5. def intensity_hist(image_file):
  6. """show some descriptive stats of some of the most relevant aspects in the dataset.
  7. Such as the min, max, median, mean of the image sizes.
  8.  
  9. Args:
  10. image_files: string. Path of image file.
  11. """
  12. img = cv2.imread(image_file)
  13.  
  14. plt.figure(figsize=(12, 8))
  15.  
  16. # axis1, show image
  17. ax1 = plt.subplot(2, 1, 1)
  18. img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
  19. ax1.imshow(img_rgb)
  20.  
  21. # axis2, show intensity histgram
  22. ax2 = plt.subplot(2, 1, 2)
  23. color_channel = ('blue','green','red')
  24. for i,col in enumerate(color_channel):
  25. histr = cv2.calcHist([img],[i],None,[256],[0,256])
  26. ax2.plot(histr,color=col, label=col)
  27. ax2.set_xlim([0,256])
  28.  
  29. ax2.legend()
  30. ax2.set_xlabel('Values')
  31. ax2.set_ylabel('Intensity')
  32. ax2.grid(True)
  33.  
  34. plt.show()
Add Comment
Please, Sign In to add comment