Appendix

1. Basics of Image Processing

Activity 1.01: Mirror Effect with a Twist

Solution:

  1. Let's start by importing the necessary libraries:

    # Load modules

    import cv2

    import numpy as np

    import matplotlib.pyplot as plt

  2. Next, let's specify the magic command for displaying images in a notebook:

    %matplotlib inline

  3. Now, we can load the image and display it using Matplotlib.

    Note

    Before proceeding, ensure that you can change the path to the images (highlighted) based on where the image is saved in your system.

    The code is as follows:

    # Load image

    img = cv2.imread("../data/lion.jpg")

    plt.imshow(img[:,:,::-1])

    plt.show()

    The output is as follows:

    Figure 1.42: Image that we are going to use in this activity

    Figure 1.42: Image ...

Get The Computer Vision Workshop now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.