I'm trying to save image (generated by GAN) in numpy.ndarray format with shape (row, col, channel)
having float value. The first strategy I found here is using PIL
from PIL import Image
img_array = np.reshape(img_array, (row, col))
img_array *= 255
img = Image.fromarray(img_array.astype(np.uint8))
img.save('foo.png')
But after seeing the result (both when plotted with matplotlib or saved as image file), it creates white artifacts such like this
Compared to plotting the array straight into matplotlib, the result is better, but create margin in the image file when saved
How do I save the image in such way the quality is the same as the plot?
nb : I have checked the value using img_array.max()
or img_array.min()
, and yes the value is beyond 0-255 threshold