Implementations
Image Reader implementations that use PIL and GDAL.
PilImageReader
- class smqtk_image_io.impls.image_reader.pil_io.PilImageReader(explicit_mode: str | None = None)[source]
Image reader that uses PIL to load the image.
This implementation may additionally raise an
IOErrorwhen failing to to load an image.- get_config() Dict[source]
Return a JSON-compliant dictionary that could be passed to this class’s
from_configmethod to produce an instance with identical configuration.In the most cases, this involves naming the keys of the dictionary based on the initialization argument names as if it were to be passed to the constructor via dictionary expansion. In some cases, where it doesn’t make sense to store some object constructor parameters are expected to be supplied at as configuration values (i.e. must be supplied at runtime), this method’s returned dictionary may leave those parameters out. In such cases, the object’s
from_configclass-method would also take additional positional arguments to fill in for the parameters that this returned configuration lacks.- Returns:
JSON type compliant configuration dictionary.
- Return type:
dict
- classmethod is_usable() bool[source]
Check whether this class is available for use.
Since certain plugin implementations may require additional dependencies that may not yet be available on the system, or other runtime conditions, this method may be overridden to check for those and return a boolean saying if the implementation is available for usable. When this method returns True, the class is declaring that it should be constructable and usable in the current environment.
By default, this method will return True unless a subclass overrides this class-method with their specific logic.
- NOTES:
This should be a class method
- When an implementation is deemed not usable, this should emit a
(user) warning, or some other kind of logging, detailing why the implementation is not available for use.
- Returns:
Boolean determination of whether this implementation is usable in the current environment.
- Return type:
bool
GdalImageReader
- class smqtk_image_io.impls.image_reader.gdal_io.GdalImageReader(load_method: str = 'tempfile', channel_order: str | Sequence[int] | None = None)[source]
Use GDAL to read raster image pixel data and returns an image matrix in the [height, width, channel] format for multi-channel imagery and just [height, width] for single channel imagery.
- get_config() Dict[source]
Return a JSON-compliant dictionary that could be passed to this class’s
from_configmethod to produce an instance with identical configuration.In the common case, this involves naming the keys of the dictionary based on the initialization argument names as if it were to be passed to the constructor via dictionary expansion.
- Returns:
JSON type compliant configuration dictionary.
- Return type:
dict
- classmethod is_usable() bool[source]
Check whether this class is available for use.
Since certain plugin implementations may require additional dependencies that may not yet be available on the system, this method should check for those dependencies and return a boolean saying if the implementation is usable.
- NOTES:
This should be a class method
When an implementation is deemed not usable, this should emit a warning detailing why the implementation is not available for use.
- Returns:
Boolean determination of whether this implementation is usable.
- Return type:
bool