About 363,000 results
Open links in new tab
  1. How do I convert a numpy array to (and display) an image?

    The Python Imaging Library can display images using Numpy arrays. Take a look at this page for sample code: Convert Between Numerical Arrays and PIL Image Objects; EDIT: As the note …

  2. python - Saving a Numpy array as an image - Stack Overflow

    May 24, 2009 · for saving a numpy array as image, U have several choices: 1) best of other: OpenCV. import cv2 cv2.imwrite('file name with extension(like .jpg)', numpy_array) 2) …

  3. Image tutorial — Matplotlib 3.10.3 documentation

    We use Pillow to open an image (with PIL.Image.open), and immediately convert the PIL.Image.Image object into an 8-bit (dtype=uint8) numpy array. img = np . asarray ( Image . …

  4. Matplotlib,how to represent array as image? - Stack Overflow

    import itertools import numpy as np import matplotlib.pyplot as plt with open('base.txt','r') as f: vst = map(int, itertools.imap(float, f)) v1=vst[::3] print type(v1) a=np.asarray(v1) print len(a) …

  5. Convert a NumPy array to an image - GeeksforGeeks

    Apr 1, 2025 · Matplotlib is commonly used for data visualization, but it can also display images from a NumPy array. The plt.imshow () function takes the NumPy array and renders it as an …

  6. 5 Best Ways to Convert Python NumPy Array to Image

    Feb 20, 2024 · By using the function matplotlib.pyplot.imsave(), one can quickly save a NumPy array as an image file. Here’s an example: The code creates a grayscale image and saves it …

  7. How to Convert a NumPy Array to PIL Image in Python

    Feb 2, 2024 · This tutorial explains how we can convert a NumPy array to a PIL image using the Image.fromarray() from the PIL package.

  8. python - NumPy to Image: A Step-by-Step Guide - arrays

    Apr 26, 2025 · To convert a NumPy array to an image and display it, we'll use two popular Python libraries: import numpy as np. # Fill the image with a specific color (e.g., blue) . import numpy …

  9. python - Viewing a NumPy array as an image - Stack Overflow

    Sep 27, 2021 · >>> import numpy as np >>> a=np.array([1,2,3]) >>> a array([1, 2, 3]) >>> a.dtype dtype('int64') >>> b=np.array([1,2,3.5]) >>> b.dtype dtype('float64') You need to convert the …

  10. Leveraging Matplotlib: Creating Stunning Images from NumPy

    Apr 26, 2025 · This method leverages Matplotlib's plotting capabilities to directly display the array as an image. However, it involves saving the image to a file and then loading it into a PIL …

  11. Some results have been removed