import numpy as np # conda install numpy
import cv2 as cv # conda install opencv
import matplotlib.pyplot as plt
#from PIL import Image # para rodar no console
def showfig(image, ucmap):
imgplot=plt.imshow(image, ucmap)
img = cv.imread("imgs/pfig01.jpg",0)
hf = cv.calcHist([img],[0],None,[256],[0,256])
plt.figure(figsize=(13,5))
plt.subplot(121),plt.imshow(img,"gray"),plt.title('Input')
plt.subplot(122),plt.plot(hf),plt.title('Hist')
plt.show()
You're giving this error
NameError Traceback (most recent call last)
<ipython-input-15-03db2af2cf65> in <module>()
7
8 img = cv.imread("imgs/pfig01.jpg",0)
----> 9 hf = cv.calcHist([img],[0],None,[256],[0,256])
10
11 plt.figure(figsize=(13,5))
NameError: name 'img' is not defined