I am loading an image using skimage.io.imread and saving the image as numpy array. Following is the inferance:
Original image: (256x512x3)
Following is the code that I execute:
img = io.imread(img_file) # 48.1 kB
i1, i2 = img[:, :256], img[:, 256:]
np.save('i1', i1) # 196.7 kB
np.save('i2', i2) # 196.7 kB
final_image = np.empty([1, 2, 256, 256, 3])
final_image[0, 0], final_image[0, 1] = i1, i2
np.save('final', final_image) # 3.1 MB
Can anyone explain why such a huge difference in the size of the image?
EDIT: dtype of i1, i2, final_image is np.float64

final_imageis of dtypenp.float_, which is likely 8 bytes per item.i1andi2isnp.float_as well. But I don't see such a surge in the size of the saved arraynp.uint8, at least it does on my system.final_mage.shape, final_image.dtypei1andi2have dtype ofuint8whereasfinal_imagehasfloat64