When I import an image as a NumPy array using the following code:
import numpy as np
from PIL import Image
imgage = Image.open('input.jpg', 'r')
width, height = imgage.size
pixel_values = np.array(imgage.getdata(), dtype=np.uint8).reshape((width, height, 3))
And, then I export it using the following code:
output = Image.fromarray(pixel_values, 'RGB')
output = img.save('output.png')
The resulting image is completely different from the input.
Can you please what the problem is? How can I fix it?