jacinle.image.codecs#

Functions

imdecode(data, *[, require_chl3, require_alpha])

Decode images in common formats (jpg, png, etc.).

jpeg_encode(img[, quality])

Encode the image with JPEG encoder.

png_encode(input[, compress_level])

Encode the image with PNG encoder.

Functions

imdecode(data, *, require_chl3=True, require_alpha=False)[source]#

Decode images in common formats (jpg, png, etc.).

Parameters:
  • data (bytes) – encoded image data

  • require_chl3 – whether to convert gray image to 3-channel BGR image

  • require_alpha – whether to add alpha channel to BGR image

Returns: uint8 color image array

jpeg_encode(img, quality=90)[source]#

Encode the image with JPEG encoder.

Parameters:
  • img (numpy.ndarray) – uint8 color image array

  • quality (int) – quality for JPEG compression

Returns bytes: encoded image data

png_encode(input, compress_level=3)[source]#

Encode the image with PNG encoder.

Parameters:
  • img (numpy.ndarray) – uint8 color image array

  • quality (int) – quality for JPEG compression

Returns bytes: encoded image data