You can use newer OpenCV python interface (if I'm not mistaken it is available since OpenCV 2.2). It natively uses numpy arrays:

import cv2
im = cv2.imread("abc.tiff")
print(type(im))

result:

<type 'numpy.ndarray'>
Answer from Andrey Kamaev on Stack Overflow
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ numpy
Image processing with Python, NumPy | note.nkmk.me
October 20, 2020 - Passing the image data read by PIL.Image.open() to np.array() returns 3D ndarray whose shape is (row (height), column (width), color (channel)). from PIL import Image import numpy as np im = np.array(Image.open('data/src/lena.jpg')) print(type(im)) ...
๐ŸŒ
scikit-image
scikit-image.org โ€บ skimage-tutorials โ€บ lectures โ€บ 00_images_are_arrays.html
Images are numpy arrays โ€” Image analysis in Python
def my_function(any_image): float_image ... are typically stored in JPEG or PNG format. Since scikit-image operates on NumPy arrays, any image reader library that provides arrays will do....
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ examples โ€บ convert-images-to-numpy-arrays
How to Convert Images to Numpy Arrays in Python - AskPython
April 21, 2026 - Pillow is the go-to library for basic image loading in Python. Pair it with numpy.asarray() and you get an array without installing anything heavy.
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ numpy โ€บ read-png-image-data-into-numpy-array-using-python.php
Read PNG image data into NumPy array using Python
September 1, 2025 - Write a NumPy program that read image data from a PNG file into a NumPy array using an image processing library like PIL or opencv. ... from PIL import Image import numpy as np # Define the path to the PNG file image_path = 'image.png' # Open ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-convert-images-to-numpy-array
How to Convert images to NumPy array? - GeeksforGeeks
September 30, 2022 - In order to get the value of each pixel of the NumPy array image, we need to print the retrieved data that got either from asarray() function or array() function.
๐ŸŒ
Pluralsight
pluralsight.com โ€บ blog โ€บ tech guides & tutorials
Importing Image Data Into NumPy Arrays | Pluralsight
April 15, 2025 - To work with an OpenCV library, you need to install it in the virtual environment using pip install opencv-contrib-python. The cv2 package provides an imread() function to load the image. It also reads a PIL image in the NumPy array format.
๐ŸŒ
GitHub
github.com โ€บ luispedro โ€บ imread
GitHub - luispedro/imread: Read images to numpy arrays ยท GitHub
IO with images and numpy arrays. Mahotas-imread is a simple module with a small number of functions: imread: Reads an image file ยท imread_multi: Reads an image file with multiple images. Currently, TIFF and STK (a TIFF sub-based format) support this function.
Find elsewhere
๐ŸŒ
Clementine Blog
clementine.hashnode.dev โ€บ how-to-read-image-from-path-and-convert-to-a-numpy-array-in-python
How to read Image from Path and Convert to a NumPy Array in Python.
March 11, 2021 - Three methods to convert an image path to a NumPy array: Use OpenCV # OpenCV import cv2 img = cv2.imread(image_path) # reads an image in the BGR format img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # BGR -> RGB Use Matplotlib # Use Matplotlib from...
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ converting-images-to-numpy
Converting Images to NumPy
Images are often converted to NumPy arrays to leverage efficient numerical computation, which is beneficial for tasks like machine learning and data analysis. from PIL import Image import numpy as np image = Image.open('path_to_image.jpg') image_array = np.array(image)
๐ŸŒ
Appdividend
appdividend.com โ€บ convert-an-image-to-numpy-array-in-python
How to Convert an Image to Numpy Array in Python
October 9, 2025 - from PIL import Image import numpy ...(img_array)) # Output: <class 'numpy.ndarray'> When you are using OpenCV, it automatically reads images as NumPy arrays in BGR order (not RGB)....
๐ŸŒ
GitHub
gist.github.com โ€บ simecek โ€บ e5a7a9de9d568b3e1a291a5982dbd3c2
Example of Reading Image Into Numpy Array ยท GitHub
Example of Reading Image Into Numpy Array ยท Display the source blob ยท Display the rendered blob Raw ยท Image+as+Numpy+Array.ipynb ยท Loading ยท Sorry, something went wrong. Reload? Sorry, we cannot display this file. Sorry, this file is invalid so it cannot be displayed.
๐ŸŒ
Javatpoint
javatpoint.com โ€บ how-to-convert-images-to-numpy-array
How to Convert Images to NumPy Array - Javatpoint
How to Convert Images to NumPy Array with tutorial, tkinter, button, overview, canvas, frame, environment set-up, first python program, etc.
๐ŸŒ
SciPy Lecture Notes
scipy-lectures.org โ€บ advanced โ€บ image_processing
2.6. Image manipulation and processing using Numpy and Scipy โ€” Scipy lecture notes
Images are arrays: use the whole numpy machinery. ... Open as an array the scikit-image logo (http://scikit-image.org/_static/img/logo.png), or an image that you have on your computer.
๐ŸŒ
Codepointtech
codepointtech.com โ€บ home โ€บ read images into numpy arrays: python"s essential guide
Read Images into NumPy Arrays: Python"s Essential Guide - codepointtech.com
January 18, 2026 - Matplotlib: Best for reading images when your primary goal is to display them within a plot or for very simple, quick reads. Once your image is a NumPy array, the possibilities are endless. Here are a couple of quick examples: You can convert a color image to grayscale by averaging the color channels or using a weighted sum (luminosity method). # Assuming img_array_pillow is an RGB image (height, width, 3) # Simple average method img_gray_avg = img_array_pillow.mean(axis=2).astype(np.uint8) # Or using OpenCV"s conversion (if starting with BGR or want specific conversion) # img_gray_cv = cv2.cvtColor(img_opencv, cv2.COLOR_BGR2GRAY) print(f"Shape of Grayscale Image: {img_gray_avg.shape}")
๐ŸŒ
Pythoninformer
pythoninformer.com โ€บ python-libraries โ€บ numpy โ€บ numpy-and-images
PythonInformer - Image processing with pillow and NumPy
October 2, 2022 - PIL creates an RGB image by default because the array has 3 colour channels. We will see later that if there are 4 channels an RGBA image is created, and if there is only 1 channel a greyscale image is created. These are defaults, it is possible to use different colour spaces using the fromarray mode parameter, see the PIL documentation. Now let's add some code to create a NumPy image and then save it: import numpy as np from PIL import Image array = np.zeros([100, 200, 3], dtype=np.uint8) array[:,:100] = [255, 128, 0] #Orange left side array[:,100:] = [0, 0, 255] #Blue right side img = Image.fromarray(array) img.save('testrgb.png')
๐ŸŒ
Linux Hint
linuxhint.com โ€บ pil-image-to-numpy-array
Linux Hint โ€“ Linux Hint
November 9, 2022 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
GitHub
github.com โ€บ foolmarks โ€บ images_to_npy
GitHub - foolmarks/images_to_npy: Converting images to numpy files ยท GitHub
To save time during training, it can be useful to convert a dataset of images to numpy arrays, pre-process them (scaling, normalization, etc) and then save as one or more binary numpy files. Each image should be read with the OpenCV imread function ...
Starred by 28 users
Forked by 10 users
Languages: Python