Hello I am reading an image with
plt.imread('photo.png')
and this returns the following shape:
100, 100, 4
What can I do to only get the rgb, that is to say
100, 100, 3
Try getting the first three values i.e. the RGB sequence (100, 100, 3) from the RGBA sequences (100, 100, 4) using the following where you leave out the alpha parameter. As per the docs, imread
returns (M, N, 3) for RGB images and (M, N, 4) for RGBA images.
rgb = plt.imread('photo.png')[:,:,:3]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With