Chapter 21 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
## /home/otoomet/R/x86_64-pc-linux-gnu-library/4.4/reticulate/python/rpytools/loader.py:120: UserWarning: Pandas requires version '1.3.6' or newer of 'bottleneck' (version '1.3.5' currently installed).
## return _find_and_load(name, import_)
import matplotlib.pyplot as plt
21.1 Loading images
= plt.imread("../img/flag-of-scotland-8x8.png") flag
## FileNotFoundError: [Errno 2] No such file or directory: '../img/flag-of-scotland-8x8.png'
flag.shape
## NameError: name 'flag' is not defined
=2)
np.set_printoptions(precision0] # R flag[:,:,
## NameError: name 'flag' is not defined
1] # G flag[:,:,
## NameError: name 'flag' is not defined
2] # B flag[:,:,
## NameError: name 'flag' is not defined
= plt.imshow(flag) _
## NameError: name 'flag' is not defined