LoadImage#
- class deeptrack.features.LoadImage(path: str | List[str] | Callable[[...], str | List[str]], load_options: dict | Callable[[...], dict] | None = None, as_list: bool | Callable[[...], bool] = False, ndim: int | Callable[[...], int] = 3, to_grayscale: bool | Callable[[...], bool] = False, get_one_random: bool | Callable[[...], bool] = False, **kwargs: Dict[str, Any])#
Bases:
Feature
Load an image from disk.
This feature attempts to load an image file using a series of file readers (imageio, numpy, Pillow, and OpenCV) until a suitable reader is found. Additional options allow for converting the image to grayscale, reshaping it to a specified number of dimensions, or treating the first dimension as a list of images.
Parameters#
- pathPropertyLike[Union[str, List[str]]]
The path(s) to the image(s) to load. Can be a single string or a list of strings.
- load_optionsPropertyLike[Dict[str, Any]], optional
Options passed to the file reader. Defaults to None.
- as_listPropertyLike[bool], optional
If True, the first dimension of the image will be treated as a list. Defaults to False.
- ndimPropertyLike[int], optional
Ensures the image has at least this many dimensions. Defaults to 3.
- to_grayscalePropertyLike[bool], optional
If True, converts the image to grayscale. Defaults to False.
- get_one_randomPropertyLike[bool], optional
If True, extracts a single random image from a stack of images. Only used when as_list is True. Defaults to False.
Raises#
- IOError
If no file reader could parse the file or the file does not exist.
Methods Summary
get
(*ign, path, load_options, ndim, ...)Load the image(s) from disk and process them.
Methods Documentation
- get(*ign: Any, path: str | List[str], load_options: Dict[str, Any] | None, ndim: int, to_grayscale: bool, as_list: bool, get_one_random: bool, **kwargs: Dict[str, Any]) ndarray #
Load the image(s) from disk and process them.
Parameters#
- pathUnion[str, List[str]]
The path(s) to the image(s) to load.
- load_optionsOptional[Dict[str, Any]]
Options passed to the file reader.
- ndimint
Ensures the image has at least this many dimensions.
- to_grayscalebool
Whether to convert the image to grayscale.
- as_listbool
Whether to treat the first dimension as a list.
- get_one_randombool
Whether to extract a single random image from a stack.
- **kwargsDict[str, Any]
Additional keyword arguments.
Returns#
- np.ndarray
The loaded and processed image(s).
Raises#
- IOError
If no file reader could parse the file or the file does not exist.