According to scipy documentation it is possible to save single channel of an image like so;
>>> x = np.zeros((255, 255))
>>> x = np.zeros((255, 255), dtype=np.uint8)
>>> x[:] = np.arange(255)
>>> imsave('/tmp/gradient.png', x)
And 3 channels of an image like so:
>>> rgb = np.zeros((255, 255, 3), dtype=np.uint8)
>>> rgb[..., 0] = np.arange(255)
>>> rgb[..., 1] = 55
>>> rgb[..., 2] = 1 - np.arange(255)
>>> imsave('/tmp/rgb_gradient.png', rgb)
However is it possible to save only 2 channels of an image as png? I have tried to mimic the above code with only 2 channels, I am greeted with the following error:
ValueError: 'arr' does not have a suitable array shape for any mode.