Challenge¶
Here's a cat.
Download the image, then convert it to a NumPy array. Then alter the array so that
- Red values become blue values
- Green values become red values
- Blue values become green values
Then plot the resulting image.
STOP
Think about what the output should look like before you create it.
Solution¶
-
Load the image with
Image.open()
from Pillow.You can inspect the image's
format
,size
, andmode
like this 👇 -
Convert the image to a NumPy array
-
Swap the color channels and convert the resuling array into an Image instance with
Image.fromarray()