Matplotlib import image as float32
On 01/07/2019 21:08, Markos wrote:
> I observed that matplotlib reads an image file (PNG) as float32:
> Please, how to read this file as int8 to get RGB in range of 0-255?
You may want to try a different library.
scikit-image's imread function will give you the image as an integer
array. This uses the imageio module under the hood.
OpenCV uses int8's for everything IIRC, but using that only makes sense
if you also want its image processing functionality
> Thank you,
>> import numpy as np
>> import matplotlib.pyplot as plt
>> import matplotlib.image as mpimg
>> imagem = mpimg.imread('lenna.png')
>> print (imagem)
> [[[0.8862745? 0.5372549? 0.49019608]
> ? [0.8862745? 0.5372549? 0.49019608]
> ? [0.8745098? 0.5372549? 0.52156866]
> ? ...
>> print (imagem.dtype)