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 Overflowscikit-image
scikit-image.org › skimage-tutorials › lectures › 00_images_are_arrays.html
Images are numpy arrays — Image analysis in Python
# --- read in the image --- image = plt.imread('../images/Bells-Beach.jpg') # --- assign each color channel to a different variable --- r = ... # FIXME: grab channel from image... g = ... # FIXME b = ...
University of Toronto
teach.cs.toronto.edu › ~csc411h › winter › lec › week2 › numpy › NumpyImgs.html
CSC411 Reading and Displaying Images using NumPy
Images can be read into numpy, and are stored as multi-dimensional arrays.
08:02
OpenCV Numpy Basics - Image Data Structure - Raspberry Pi - YouTube
How to load Images to Numpy and Vice versa in python.
How to convert image into NumPy array? - YouTube
16:49
Manipulate Images using Python - NumPy, Scikit-Image, and Matplotlib ...
19:39
How to convert images to NumPy arrays - 20 - YouTube
12:29
Read NAIP images as numpy arrays with Python and GDAL - YouTube
Top answer 1 of 15
202
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'>
2 of 15
108
PIL (Python Imaging Library) and Numpy work well together.
I use the following functions.
from PIL import Image
import numpy as np
def load_image( infilename ) :
img = Image.open( infilename )
img.load()
data = np.asarray( img, dtype="int32" )
return data
def save_image( npdata, outfilename ) :
img = Image.fromarray( np.asarray( np.clip(npdata,0,255), dtype="uint8"), "L" )
img.save( outfilename )
The 'Image.fromarray' is a little ugly because I clip incoming data to [0,255], convert to bytes, then create a grayscale image. I mostly work in gray.
An RGB image would be something like:
out_img = Image.fromarray( ycc_uint8, "RGB" )
out_img.save( "ycc.tif" )
Pythoninformer
pythoninformer.com › python-libraries › numpy › numpy-and-images
PythonInformer - Image processing with pillow and NumPy
October 2, 2022 - In this section, we will learn how to use NumPy to store and manipulate image data. We will use the Python Imaging Library (PIL) to read and write data to standard image file formats.
AskPython
askpython.com › python › examples › convert-images-to-numpy-arrays
How to Convert Images to Numpy Arrays in Python - AskPython
April 21, 2026 - OpenCV is faster than Pillow and the preferred choice when you are processing many images or need tight integration with computer vision code. It reads images as BGR by default, which trips up many people coming from other libraries. import cv2 import numpy as np arr = cv2.imread('sample.png') print(type(arr)) print(arr.dtype) print(arr.shape) print(f"Value range: [{arr.min()}, {arr.max()}]")
Chris35wills
chris35wills.github.io › courses › PythonPackages_numpy › numpy_io_scipy_image
Read in data using scipy (image)
You now have access to the routines available within scipy’s misc module. To read in the image, type the following: dog=misc.imread('/path/to/file/puppy.png') type(dog) You have now created a numpy array object holding the image information.
Stack Overflow
stackoverflow.com › questions › 62602397 › how-can-i-read-a-numpy-array-image-with-opencv
python - How can I read a numpy array image with OpenCV? - Stack Overflow
import numpy as np import cv2 images = np.load("file.npy") for i, img_array in enumerate(images): if len(img_array.shape) == 2: img = img_array elif len(img_array.shape) == 3: img = cv2.cvtColor(img_array, cv2.COLOR_RGB2BGR) gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) _, thr_img = cv2.threshold(gray_img, 0, 255, cv2.THRESH_OTSU) cv2.imshow(f"Thresholded Image {i}", thr_img) cv2.waitKey(0) cv2.destroyAllWindows()
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.
DataCamp
datacamp.com › doc › numpy › converting-images-to-numpy
Converting Images to NumPy
This example loads an image named `example.jpg` and converts it into a NumPy array, printing its shape, which represents the dimensions of the image in the format (height, width, channels).