less than 1 minute read

converting 3channels from Numpy ndarray

I ran into the error at work converting pillow instance to numpy array.

# Converting Pillow instance with three channels
#PIL_image = PIL_image.convert("RGB") -> It makes error. imgArray = np.asarray(PIL_image.convert("RGB")) doesn't make error.

# Casting to Pillow to Numpy
imgArray = np.asarray(PIL_image.convert("RGB"))

Reference

https://stackoverflow.com/questions/57565234/pil-not-always-using-3-channels-for-png

Categories:

Updated:

Leave a comment