mt.imageio.imread

Extra imread functions.

Functions

async mt.imageio.imread.imread_asyn(filepath, plugin: str | None = None, extension: str | None = None, format_hint: str | None = None, plugin_kwargs: dict = {}, context_vars: dict = {}) ndarray

An asyn function that loads an image file using imageio.v3.imread().

Parameters:
  • filepath (str) – local filepath to the image

  • plugin (str, optional) – The plugin in imageio.v3.imread() to use. If set to None (default) imread will perform a search for a matching plugin. If not None, this takes priority over the provided format hint (if present).

  • extension (str, optional) – Passed as-is to imageio.v3.imread(). If not None, treat the provided ImageResource as if it had the given extension. This affects the order in which backends are considered.

  • format_hint (str, optional) – A format hint for func:`imageio.v3.imread to help optimize plugin selection given as the format’s extension, e.g. ‘.png’. This can speed up the selection process for ImageResources that don’t have an explicit extension, e.g. streams, or for ImageResources where the extension does not match the resource’s content.

  • plugin_kwargs (dict) – Additional keyword arguments to be passed as-is to the plugin’s read call of imageio.v3.imread().

  • context_vars (dict) – a dictionary of context variables within which the function runs. It must include context_vars[‘async’] to tell whether to invoke the function asynchronously or not.

Returns:

the loaded image

Return type:

numpy.ndarray

Notes

This imread version differs from cv2.imread() in that by default the output color image has RGB channels instead of OpenCV’s old style BGR channels since it uses imageio and pillow plugin by default.

Raises:
  • ValueError

  • OSError

See also

imageio.v3.imread

the underlying imread function

mt.imageio.imread.immdecode(data: bytes, plugin: str | None = None, extension: str | None = None, format_hint: str | None = None, plugin_kwargs: dict = {}) Image

Decodes an image file content and its metadata using :module:`imageio.v3`.

Parameters:
  • data (bytes) – the content of an image file that has been read into memory

  • plugin (str, optional) – The plugin in imageio.v3.imread() to use. If set to None (default) imread will perform a search for a matching plugin. If not None, this takes priority over the provided format hint (if present).

  • extension (str, optional) – Passed as-is to imageio.v3.imread(). If not None, treat the provided ImageResource as if it had the given extension. This affects the order in which backends are considered.

  • format_hint (str, optional) – A format hint for func:`imageio.v3.imread to help optimize plugin selection given as the format’s extension, e.g. ‘.png’. This can speed up the selection process for ImageResources that don’t have an explicit extension, e.g. streams, or for ImageResources where the extension does not match the resource’s content.

  • plugin_kwargs (dict) – Additional keyword arguments to be passed as-is to the plugin’s read call of imageio.v3.imread().

Returns:

the loaded image with metadata

Return type:

mt.opencv.image.Image

Notes

This immread version loads a stardard image file that come with metadata using :module:`imageio.v3`. However, it uses:class:mt.opencv.Image to store the result.

Raises:

ValueError

See also

imageio.v3.imread

the underlying imread function

imageio.v3.immeta

the underlying immeta function

async mt.imageio.imread.immread_asyn(filepath, plugin: str | None = None, extension: str | None = None, format_hint: str | None = None, plugin_kwargs: dict = {}, context_vars: dict = {}) Image

An asyn function that loads an image file and its metadata using :module:`imageio.v3`.

Parameters:
  • filepath (str) – local filepath to the image

  • plugin (str, optional) – The plugin in imageio.v3.imread() to use. If set to None (default) imread will perform a search for a matching plugin. If not None, this takes priority over the provided format hint (if present).

  • extension (str, optional) – Passed as-is to imageio.v3.imread(). If not None, treat the provided ImageResource as if it had the given extension. This affects the order in which backends are considered.

  • format_hint (str, optional) – A format hint for func:`imageio.v3.imread to help optimize plugin selection given as the format’s extension, e.g. ‘.png’. This can speed up the selection process for ImageResources that don’t have an explicit extension, e.g. streams, or for ImageResources where the extension does not match the resource’s content.

  • plugin_kwargs (dict) – Additional keyword arguments to be passed as-is to the plugin’s read call of imageio.v3.imread().

  • context_vars (dict) – a dictionary of context variables within which the function runs. It must include context_vars[‘async’] to tell whether to invoke the function asynchronously or not.

Returns:

the loaded image with metadata

Return type:

mt.opencv.image.Image

Notes

This immread version combines mt.opencv.image.immload() (if the extension is ‘.imm’) and immdecode() (otherwise). In any case, it uses mt.opencv.Image to store the result.

Raises:
  • ValueError

  • OSError

See also

mt.opencv.image.immload

the underlying immload function for json and h5 formats

immdecode

the underlying immdecode function

mt.imageio.imread.immread(filepath, plugin: str | None = None, extension: str | None = None, format_hint: str | None = None, plugin_kwargs: dict = {}) Image

Loads an image file and its metadata using :module:`imageio.v3`.

Parameters:
  • filepath (str) – local filepath to the image

  • plugin (str, optional) – The plugin in imageio.v3.imread() to use. If set to None (default) imread will perform a search for a matching plugin. If not None, this takes priority over the provided format hint (if present).

  • extension (str, optional) – Passed as-is to imageio.v3.imread(). If not None, treat the provided ImageResource as if it had the given extension. This affects the order in which backends are considered.

  • format_hint (str, optional) – A format hint for func:`imageio.v3.imread to help optimize plugin selection given as the format’s extension, e.g. ‘.png’. This can speed up the selection process for ImageResources that don’t have an explicit extension, e.g. streams, or for ImageResources where the extension does not match the resource’s content.

  • plugin_kwargs (dict) – Additional keyword arguments to be passed as-is to the plugin’s read call of imageio.v3.imread().

  • context_vars (dict) – a dictionary of context variables within which the function runs. It must include context_vars[‘async’] to tell whether to invoke the function asynchronously or not.

Returns:

the loaded image with metadata

Return type:

mt.opencv.image.Image

Notes

This immread version combines mt.opencv.image.immload() (if the extension is ‘.imm’) and immdecode() (otherwise). In any case, it uses mt.opencv.Image to store the result.

Raises:
  • ValueError

  • OSError

See also

mt.opencv.image.immload

the underlying immload function for json and h5 formats

immdecode

the underlying immdecode function