'Same shape Numpy arrays have different memory size
I'm using PIL to import an image and transform it into a Numpy array, of shape (369, 103, 4). I then normalize the data and save both arrays. But when I do, the first image has a memory size of 149 KB, while the normalized one is 1.188 KB. How is that possible? How can I modify my code so that I don't end up with data almost x10 times the size of the original? The code I use is as follows:
from PIL import Image
import numpy as np
import os
path = os.getcwd()
temp = Image.open('{}/someimage.png'.format(path))
imagedata = np.asarray(temp)
def NormalizeData(data):
return (data - np.min(data)) / (np.max(data) - np.min(data))
imagedata2 = NormalizeData(imagedata)
np.save('firstimage.npy', imagedata)
np.save('secondimage.npy', imagedata2)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
