Today, I came across a weird thing that I cannot explain and cannot find an answer to. Maybe I have some fundamental misunderstanding and I am not seeing the obvious, but I guess I am at the point where I will bite the bullet of being called out over now knowing what is going on.
I am loading some image data using PIL and converting it into a numpy array. Nothing fancy here. However, I am then changing the data type from integer to float so I can normalize the RGB channels in a later step.
I would expect that changing the datatype from int to float wouldn't really change the image in any way. However ...
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
im = Image.open("test.jpg")
before the dtype change:
plt.imshow(np.array(im))
after the dtype change:
plt.imshow(np.array(im).astype(float))
Is this what one would expect? If so ... why? What am I missing?
Cheers & thanks in advance!!



