-
Book Overview & Buying
-
Table Of Contents
The Computer Vision Workshop
By :
To compute the histogram of an image, we are going to use a command from a Python library named Matplotlib. Matplotlib is a vast library, and the module you need from it to plot a histogram is called pyplot. The pyplot module gives you access to the plotting functionality of Matplotlib. This plotting functionality is what we need to display histograms.
The code you will need to import this module is as follows:
import matplotlib.pyplot as plt
Alternatively, you can also import the pyplot module as follows:
from matplotlib import pyplot as plt
Following is an explanation of the syntax for importing the pyplot module:
Figure 3.2: Explanation of the syntax
Using Matplotlib, you can also display images on the console itself, unlike cv2.imshow, which opens a new window to display the image.
To plot a grayscale image (img) using Matplotlib, you can use the following code:
imgplot...