πŸ’» Activity 3.2: Drawing a Blue β€œL” on an Image using NumPy and Matplotlib#

Objective#

In this activity, you will practice using NumPy for image manipulation and learn how to draw on images using array indexing. You will load an image using Matplotlib, and then use NumPy to modify the image by drawing a blue letter β€œL” on the left side of the image. This exercise will help you understand how image data is structured and manipulated in Python.

Instructions#

In the code cell below, complete each step sequentially.

Step 1: Import the necessary modules:

  • Import matplotlib.pyplot as plt.

  • Import matplotlib.image as image.

  • Import numpy as np.

Step 2: Load the image:

  • Use image.imread() to load the Drexel University logo image from ./figs/Drexel_Logo.png.

Step 3: Modify the image pixels:

  • Set specific rectangular regions in the image to a custom color using indexing. Use the following information for the color and position:

    Size:

    • from row 10 to row 59 (inclusive) and from column 250 to column 289 (inclusive)

    Color:

    • The color is specified as [0, 47, 108, 1], which represents an RGB color with the following values:

      • Red: 0

      • Green: 47

      • Blue: 108

      • Alpha (Transparency): 1 (indicating full opacity)

Step 4: Display the modified image:

  • Use plt.imshow() to display the modified image.

Step 6: Run the code to see the modified image with the specified color changes.

# import your functions here
...

# use imread to load the images
...

# Write the letter L using indexing
...

# display the image
...

Challenge Problem: Can you draw the letter β€œD”?#

The letter D is much harder to draw on an image because it has a curve. Try to interact with ChatGPT to see if you can add a letter D on the left-hand side of the image.