weaver.transform.tiff
Module Contents
- weaver.transform.tiff.normalize_band(image_band: numpy.ndarray) numpy.ndarray[source]
Normalize a single band of an image to the range [0, 1].
- Parameters:
image_band – The image band to normalize.
- Returns:
The normalized image band.
- class weaver.transform.tiff.Tiff(file_path: str)[source]
A class for working with TIFF files, including GeoTIFFs and multi-page TIFFs.
- Variables:
file_path (str) – The file path to the TIFF image.
dataset (rasterio.Dataset) – The rasterio dataset for GeoTIFFs.
is_geotiff (bool) – A flag indicating whether the image is a GeoTIFF.
images (List[np.ndarray]) – The list of image arrays for multi-page TIFFs.
_images (List[np.ndarray]) – A copy of the list of image arrays.
nb_bands (int) – The number of bands in the GeoTIFF.
width (int) – The width of the image.
height (int) – The height of the image.
bands (dict) – A dictionary of band indexes and their data types.
coordinates (Tuple[Tuple[float, float], Tuple[float, float]]) – The coordinates for the GeoTIFF.
crs (rasterio.crs.CRS) – The coordinate reference system for the GeoTIFF.
Initialize the Tiff object with the given file path.
- Parameters:
file_path – The file path to the TIFF image.
- property range: range[source]
Get the range of valid band indexes for the TIFF file.
- Returns:
A range object representing valid band indexes.
- get_band(index: int) numpy.ndarray | None[source]
Retrieve a specific band of the image by index.
- Parameters:
index – The band index to retrieve.
- Returns:
The band as a NumPy array, or None if not found.
- Raises:
RuntimeError – If the band index is invalid or data cannot be read.
- get_images(red_band: int = 1, green_band: int = 2, blue_band: int = 3) List[PIL.Image.Image][source]
Retrieve RGB images by combining bands from a GeoTIFF or multi-page TIFF.
- Parameters:
red_band – The band index for the red channel.
green_band – The band index for the green channel.
blue_band – The band index for the blue channel.
- Returns:
A list of PIL Image objects representing the RGB image(s).