Skip to content

Image Sets

siapy.entities.imagesets

SpectralImageSet dataclass

SpectralImageSet(
    spectral_images: list[SpectralImage] | None = None,
)
Source code in siapy/entities/imagesets.py
19
20
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,
)
Source code in siapy/entities/imagesets.py
34
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
@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.spy_open(header_path=hdr_path)
            for hdr_path in track(header_paths, description="Loading spectral images...")
        ]
    else:
        spectral_images = [
            SpectralImage.spy_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)
Source code in siapy/entities/imagesets.py
74
75
76
77
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)
Source code in siapy/entities/imagesets.py
79
80
def sort(self, key: Any = None, reverse: bool = False):
    self.images.sort(key=key, reverse=reverse)