asi_core.io

This module provides input/output functionalities, e.g. reading and writing from/to files.

Functions

load_image(img_file[, format])

Loads an image from a file and converts it to the specified format.

load_images(img_files[, format, ignore_errors])

Loads multiple images from a list of file paths.

Module Contents

asi_core.io.load_image(img_file, format='rgb')

Loads an image from a file and converts it to the specified format.

Parameters:
  • img_file – Path to the image file.

  • format – Desired image format (‘bgr’, ‘rgb’, or ‘gray’). Default is ‘rgb’.

Returns:

Loaded image as a NumPy array.

Raises:
  • FileNotFoundError – If the file does not exist.

  • IOError – If the file cannot be read.

  • NotImplementedError – If the specified format is not supported.

asi_core.io.load_images(img_files, format='rgb', ignore_errors=False)

Loads multiple images from a list of file paths.

Parameters:
  • img_files – List of image file paths.

  • format – Desired image format (‘bgr’, ‘rgb’, or ‘gray’). Default is ‘rgb’.

  • ignore_errors – If True, ignores missing or unreadable files and logs warnings. If False, raises exceptions for such cases. Default is False.

Returns:

List of successfully loaded images as NumPy arrays.

Raises:
  • FileNotFoundError – If a file does not exist (unless ignore_errors is True).

  • IOError – If a file cannot be read (unless ignore_errors is True).

  • Exception – If an unexpected error occurs during loading.