MISImageFile
- class misalign.model.image.MISImageFile(image_filepath: Path | str | None = None, **image_data)
Access image data and information from an image file.
- __init__(image_filepath: Path | str | None = None, **image_data)
Initialize a MISImageFile from an image filepath.
- Parameters:
- image_filepathPath | str | None
File path to an image file.
- **image_datakwargs
Any other passed kwargs will be kept in self._dict and should be JSON dump-able objects.
Methods
__init__([image_filepath])Initialize a MISImageFile from an image filepath.
Checks if image filepath is a file.
find_image_path(mis_fp[, update])Find, and optionally update, image filepaths.
for_json()Returns a dictionary compatible with JSON.dump().
Attributes
Get the shape of the image.
- __array__() ndarray
Get image array.
- Returns:
- arraynp.ndarray
Numpy array of the image file.
- __str__()
String representation of the Image.
- Returns:
- str
Description including image name and shape.
- check_image_path() bool
Checks if image filepath is a file.
- Returns:
- bool
True if self.image_filepath is a file.
- find_image_path(mis_fp: Path | str, update: bool = True) Path | None
Find, and optionally update, image filepaths.
Checks stored location. Checks mis filepath folder for matching name.
- Parameters:
- mis_fp:Path|str,
Filepath to MISProject, expected to be in the same folder as the image file.
- update:bool=True
If true when a matching file is found it will replace self.image_filepath.
- Returns:
- return_pathPath | None
If a matching path is found it is returned, else None is returned.
- for_json() dict
Returns a dictionary compatible with JSON.dump().
- Returns:
- image_datadict
JSON dump-able representation of image information.
- property shape: tuple[int, ...]
Get the shape of the image.
- Returns:
- shapetuple[int]
Tuple of ints describing the shape in numpy order - row, col, depth - (1200,1600,3).
Notes
shape only opens the image once, and then only if the image hasn’t already been accessed. It acts cache-like and can be accessed on-demand without needing to store it separately.