python – How to use imageio imread to get a multi channel array (RGB) from a single channel image (grayscale)?

Python – How To Use Imageio Imread To Get A Multi Channel Array (Rgb) From A Single Channel Image (Grayscale)?

python – How to use imageio imread to get a multi channel array (RGB) from a single channel image (grayscale)?

Following the documentation hyperlink you supplied, you possibly can see a navigation merchandise Docs for the formats fairly outstanding on the left aspect. For instance, lets test the PNG format entry, since PNG helps single channel photographs. Theres a part Parameters for reading: You want to present a correct Pillow format string, for RGB photographs, its RGB. The parameter to be used is known as pilmode. Lets test that:

import imageio

im = imageio.imread(path/to/some/singlechannelimage.png)
print(im.form)

im3d = imageio.imread(path/to/some/singlechannelimage.png, pilmode=RGB)
print(im3d.form)

If I run that for some single channel PNG, I get:

(639, 379)
(639, 379, 3)

Thats what you need, I suppose.

----------------------------------------
System data
----------------------------------------
Platform:      Windows-10-10.0.16299-SP0
Python:        3.8.5
imageio:       2.9.0
----------------------------------------

python – How to use imageio imread to get a multi channel array (RGB) from a single channel image (grayscale)?

Related posts on python :

Leave a Reply

Your email address will not be published. Required fields are marked *