How to convert RGB PIL image to numpy array with 3 channels? How to convert RGB PIL image to numpy array with 3 channels? numpy numpy

How to convert RGB PIL image to numpy array with 3 channels?


The fourth layer is the transparency value for image formats that support transparency, like PNG. If you remove the 4th value it'll be a correct RGB image without transparency.

EDIT:

Example:

>>> import PIL.Image>>> image = PIL.Image.open('../test.png')>>> import numpy as np>>> image = np.array(image)>>> image.shape(381, 538, 4)>>> image[...,:3].shape(381, 538, 3)