Practical Computer Vision
上QQ阅读APP看书,第一时间看更新

Matplotlib

This is a popular Python package for plotting and displaying data and images. To use in Python, the scripts is as follows:

import matplotlib.pyplot as plt 

If we want to plot inside Jupyter notebook, add the following command:

%matplotlib inline 

An example function to display an image is as follows:

def plot_img(input_image): 
"""
Takes in image
Plots image using matplotlib
"""
plt.figure(figsize=(12,8))

# change color channels order for matplotlib
plt.imshow(input_image)

# For easier view, turn off axis around image
plt.axis('off')
plt.show()