how to open image as rgb file when using imageio

user288609 picture user288609 · Apr 7, 2018 · Viewed 8k times · Source

I have an existing code segment reading image using scipy.misc

imref = misc.imread(self.file_image, False, "RGB")

If I would like to replace it with imageio, how to do that, can I just use

imref = imageio.imread(self.file_image, False). 

I am not clear where to setup the "RGB" parameter while using imageio.imread.

Answer

Hirabayashi Taro picture Hirabayashi Taro · Apr 7, 2018

As explained in the docs you can use the keyword argument pilmode to specify the modality, while scipy flatten is replaced by as_gray. So in your case:

imref = imageio.imread(self.file_image, as_gray=False, pilmode="RGB")