How numpy preserves matrices with the same size of data

I now have a batch of images that I want to convert to numpy data to save, but the image size is not fixed (I don"t want resize)

for example, a. Shapee = (3rec 2jue 9), b. Shapee = (3pr 3pr 8), how to merge a meme b into c? That is to say, to realize c [0] = a ~ ~ c [1] = b?

so I would like to ask, is there any way to save these inconsistent pictures in the form of numpy.array?

Feb.28,2021

use the pillow module to convert all kinds of pictures into pixel sets, then convert them to numpy arrays, and finally save them to a file.

Please refer to the following code

-sharp -*- coding: utf-8 -*-
from PIL import Image
import numpy as np


def images_to_array(image_files, array_file):
    """  numpy  .npy 
    """
    data = []
    for filename in image_files:
        data.append(np.array(Image.open(filename)))
    np.save(array_file, data)


def load_images(array_file):
    """  .npy 
    """
    return np.load(array_file)


images_to_array(['1.png', '2.png'], '1.npy')
load_images('1.npy')

references

  1. https://pillow.readthedocs.io.
  2. https://docs.scipy.org/doc/nu.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7638-1e52.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7638-1e52.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?