Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- from matplotlib import pyplot as plt
- def intensity_hist(image_file):
- """show some descriptive stats of some of the most relevant aspects in the dataset.
- Such as the min, max, median, mean of the image sizes.
- Args:
- image_files: string. Path of image file.
- """
- img = cv2.imread(image_file)
- plt.figure(figsize=(12, 8))
- # axis1, show image
- ax1 = plt.subplot(2, 1, 1)
- img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
- ax1.imshow(img_rgb)
- # axis2, show intensity histgram
- ax2 = plt.subplot(2, 1, 2)
- color_channel = ('blue','green','red')
- for i,col in enumerate(color_channel):
- histr = cv2.calcHist([img],[i],None,[256],[0,256])
- ax2.plot(histr,color=col, label=col)
- ax2.set_xlim([0,256])
- ax2.legend()
- ax2.set_xlabel('Values')
- ax2.set_ylabel('Intensity')
- ax2.grid(True)
- plt.show()
Add Comment
Please, Sign In to add comment