There are a tons of image already – instead of going though the pain staking process of creating by hand our own images, I am going to use an image I already captured.
And yes, it is of my three cats. I am also adding to the collection of cat images on the internet.
Here is the image below – feel free to use it in any of the examples.
![Image Processing : Python Read Image File and Convert into an Array 1 thecats](https://jamiestarling.com/wp-content/uploads/2022/06/thecats.jpg)
The python code below uses PILLOW to read in the image, and then using NUMPY we can convert it into an array. Since it is a color image it will become a 3d array with the shape of 844,600,3.
#%%
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
# Image File we are loading
imageFile = r"D:\temp\thecats.jpg"
# Pillow Image Object
inputImage = Image.open(imageFile)
# Convert To Numpy Array
imageArray = np.array(inputImage)
# Using matplot to load the array into their image display function
plt.imshow(imageArray)
# Shows the Image
plt.show()
Color images are great – however they do require some more RAM and processing power. Up next we will take a look at various ways to convert a color image to black and white. This will greatly speed things up on lower powered devices.
See the Image Processing Table of Contents
Have a Project or Idea!?
Seeking Bespoke Technology Solutions?
Contact me today to discover how personalized, high-end tech solutions can meet your unique requirements.