-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
What did you do?
I am trying to create a PNG image from a Numpy Array. Before converting the array, I transformed values using multiplication.
What did you expect to happen?
I would expect that the array values used as input correspond 1 to 1 with the output, no matter how they were computed.
What actually happened?
When I multiply my initial array using a vector, the final image has wrong pixel values (lots of zeros). However, if I replace the vector with a scalar the pixel values are correct.
What are your OS, Python and Pillow versions?
- OS: MacOS
- Python: 3.8
- Pillow: 8.0.1
import numpy as np
from PIL import Image
vector = np.ones((5, 5, 3)).astype("uint8") * np.array([3])
scalar = np.ones((5, 5, 3)).astype("uint8") * 3
assert np.array_equal(vector, scalar)
vector_img = Image.fromarray(vector, mode="RGB")
scalar_img = Image.fromarray(scalar, mode="RGB")
assert np.array_equal(np.array(vector_img), np.array(scalar_img))