Skip to content

Image Sets

siapy.entities.imagesets

SpectralImageSet dataclass

SpectralImageSet(spectral_images: list[SpectralImage] | None = None)
PARAMETER DESCRIPTION
spectral_images

TYPE: list[SpectralImage] | None DEFAULT: None

Source code in siapy/entities/imagesets.py
20
21
def __init__(self, spectral_images: list[SpectralImage] | None = None):
    self._images = spectral_images if spectral_images is not None else []

images property

cameras_id property

cameras_id: list[str]

from_paths classmethod

from_paths(*, header_paths: Sequence[str | Path], image_paths: Sequence[str | Path] | None = None)
PARAMETER DESCRIPTION
header_paths

TYPE: Sequence[str | Path]

image_paths

TYPE: Sequence[str | Path] | None DEFAULT: None

Source code in siapy/entities/imagesets.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@classmethod
def from_paths(
    cls,
    *,
    header_paths: Sequence[str | Path],
    image_paths: Sequence[str | Path] | None = None,
):
    if image_paths is not None and len(header_paths) != len(image_paths):
        raise InvalidInputError(
            {
                "header_paths_length": len(header_paths),
                "image_paths_length": len(image_paths),
            },
            "The length of hdr_paths and img_path must be equal.",
        )

    if image_paths is None:
        spectral_images = [
            SpectralImage.envi_open(header_path=hdr_path)
            for hdr_path in track(
                header_paths, description="Loading spectral images..."
            )
        ]
    else:
        spectral_images = [
            SpectralImage.envi_open(header_path=hdr_path, image_path=img_path)
            for hdr_path, img_path in track(
                zip(header_paths, image_paths),
                description="Loading spectral images...",
            )
        ]
    logger.info("Spectral images loaded into memory.")
    return cls(spectral_images)

images_by_camera_id

images_by_camera_id(camera_id: str)
PARAMETER DESCRIPTION
camera_id

TYPE: str

Source code in siapy/entities/imagesets.py
77
78
79
80
def images_by_camera_id(self, camera_id: str):
    ids = np.array([image.camera_id for image in self.images])
    indices = np.nonzero(ids == camera_id)[0]
    return [image for idx, image in enumerate(self.images) if idx in indices]

sort

sort(key: Any = None, reverse: bool = False)
PARAMETER DESCRIPTION
key

TYPE: Any DEFAULT: None

reverse

TYPE: bool DEFAULT: False

Source code in siapy/entities/imagesets.py
82
83
def sort(self, key: Any = None, reverse: bool = False):
    self.images.sort(key=key, reverse=reverse)