pysdic.Image.from_file#

classmethod Image.from_file(file_path, **kwargs)[source]#

Create an pysdic.Image object by loading image data from a file.

The file is read with OpenCV (cv2.IMREAD_UNCHANGED): the dtype of the file is kept (e.g. numpy.uint16 for a 16-bit PNG, numpy.float32 for a float TIFF).

Warning

OpenCV reads color images in BGR order (BGRA with an alpha channel).

Note

Requires the optional dependency cv2 (pip install opencv-python).

Parameters:
  • file_path (Union[str, os.PathLike]) – The path to the image file to be loaded.

  • **kwargs – Keyword arguments of pysdic.Image (roi, ku, kv, default_value, auto_construct).

Returns:

An pysdic.Image object initialized with the image data loaded from the specified file.

Return type:

pysdic.Image

Raises:

Examples

Create an pysdic.Image object by loading image data from a file.

1from pysdic import Image
2
3image = Image.from_file("path_to_image.png")