Say that I have a RGB image:
from skimage import data
img = data.astronaut()
print(img.shape) # (512, 512, 3)
Is there a succinct numpy command to unpack it along the color channels:
R, G, B = np.unpack(img, 2) # ?
What I am doing is using comprehension:
R, G, B = (img[:, :, i] for i in range(3))
But is there no simpler command?
Alternatively you can use np.rollaxis -
R,G,B = np.rollaxis(img,2)
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