pysdic.Image.from_file#
- classmethod Image.from_file(file_path, **kwargs)[source]#
Create an
pysdic.Imageobject 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.uint16for a 16-bit PNG,numpy.float32for 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.Imageobject initialized with the image data loaded from the specified file.- Return type:
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If OpenCV cannot read the file as an image.
Examples
Create an
pysdic.Imageobject by loading image data from a file.1from pysdic import Image 2 3image = Image.from_file("path_to_image.png")