imgutils.data.decode

rgb_decode

imgutils.data.decode.rgb_decode(data, order_: str = 'CHW') Image[source]
Overview:

Decode numpy data to PIL.Image.Image.

Parameters:
  • data – Original numpy data (both np.uint8 and np.float32 are supported).

  • order – Order of the given data.

Returns:

Decoded pil image object.

Examples::
>>> from PIL import Image
>>> from imgutils.data import rgb_encode, rgb_decode
>>>
>>> image = Image.open('custom_image.jpg')
>>> data = rgb_encode(image)
>>> data_cwh = rgb_encode(image, order_='CWH')
>>> data_int = rgb_encode(image, use_float=False)
>>>
>>> rgb_decode(data)
<PIL.Image.Image image mode=RGB size=1606x1870 at 0x7FB9B89BBDC0>
>>> rgb_decode(data_cwh, order_='CWH')
<PIL.Image.Image image mode=RGB size=1606x1870 at 0x7FB9B89BBE50>
>>> rgb_decode(data_int)
<PIL.Image.Image image mode=RGB size=1606x1870 at 0x7FB9B89BBDF0>

Note

rgb_decode() is the inverse operation of imgutils.data.encode.rgb_encode().