Chapter 20 Working With Images {working-with-images}

Images are a valueable potential source of information, and image processing, including image recognition, is also an important application of machine learning.

We assume you have loaded the following packages:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

20.1 Loading images

flag = plt.imread("../img/flag-of-scotland-8x8.png")
## Error: FileNotFoundError: [Errno 2] No such file or directory: '../img/flag-of-scotland-8x8.png'
flag.shape
## Error: NameError: name 'flag' is not defined
np.set_printoptions(precision=2)
flag[:,:,0]  # R
## Error: NameError: name 'flag' is not defined
flag[:,:,1]  # G
## Error: NameError: name 'flag' is not defined
flag[:,:,2]  # B
## Error: NameError: name 'flag' is not defined
_ = plt.imshow(flag)
## Error: NameError: name 'flag' is not defined