Skip to content

Image Sets

siapy.entities.imagesets

SpectralImageSet dataclass

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

images property

cameras_id property

cameras_id: list[str]

spy_open classmethod

spy_open(
    *,
    header_paths: Sequence[str | Path],
    image_paths: Sequence[str | Path] | None = None,
) -> SpectralImageSet
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 spy_open(
    cls,
    *,
    header_paths: Sequence[str | Path],
    image_paths: Sequence[str | Path] | None = None,
) -> "SpectralImageSet":
    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)

rasterio_open classmethod

rasterio_open(
    *, filepaths: Sequence[str | Path]
) -> SpectralImageSet
Source code in siapy/entities/imagesets.py
66
67
68
69
70
71
72
73
74
75
76
77
@classmethod
def rasterio_open(
    cls,
    *,
    filepaths: Sequence[str | Path],
) -> "SpectralImageSet":
    spectral_images = [
        SpectralImage.rasterio_open(filepath)
        for filepath in track(filepaths, description="Loading raster images...")
    ]
    logger.info("Raster images loaded into memory.")
    return cls(spectral_images)

images_by_camera_id

images_by_camera_id(
    camera_id: str,
) -> list[SpectralImage[Any]]
Source code in siapy/entities/imagesets.py
87
88
89
90
def images_by_camera_id(self, camera_id: str) -> list[SpectralImage[Any]]:
    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) -> None
Source code in siapy/entities/imagesets.py
92
93
def sort(self, key: Any = None, reverse: bool = False) -> None:
    self.images.sort(key=key, reverse=reverse)