ImageBase#
Main API Methods
This are most important functions to be used for image classes
|
Project 3D coordinates into image pixel coordinates. |
|
Map the image center pixel to 3D coordinates. |
|
Map footprint of image to 3D. |
|
Map image pixel coordinates to 3D coordinates. |
additional helpful Methods
|
Create an image model from a parameter dictionary. |
|
Return the image reference position in the target CRS. |
Properties
Return the image model type. |
|
Return image parameters as a dictionary. |
|
Return whether the image is geo-referenced. |
|
Return the image world CRS. |
|
Return images CRS as wkt string |
|
Return images CRS as proj4 string |
|
Return width of image (column number) |
|
Return height of image (row number) |
|
Return shape of image as tuple(width, height) |
- class weitsicht.ImageBase(width: float | int, height: float | int, mapper: MappingBase | None = None, crs: CRS | None = None)[source]#
Base class for image models.
This base class defines a common API for projecting 3D coordinates into image pixel coordinates and mapping image pixels to 3D coordinates (via an optional
MappingBase).Coordinate system conventions: - Image pixel CRS: x points right, y points down (origin at top-left pixel edge). - World CRS: any cartesian CRS; for mapping it is usually best to use a projected CRS.
Subclasses must implement: - from_dict - type - param_dict - is_geo_referenced - center - position_to_crs - project - map_center_point - map_footprint - map_points
- Parameters:
width (float | int)
height (float | int)
mapper (MappingBase | None)
crs (CRS | None)
- __init__(width: float | int, height: float | int, mapper: MappingBase | None = None, crs: CRS | None = None)[source]#
Initialize the image base class.
- Parameters:
width (float | int) – Image width in pixels.
height (float | int) – Image height in pixels.
mapper (MappingBase | None) – Mapping instance, defaults to
None.crs (CRS | None) – World CRS of the image, defaults to
None.
- property mapper: MappingBase | None#
- abstractmethod classmethod from_dict(param_dict: dict, mapper: MappingBase | None = None) ImageBase[source]#
Create an image model from a parameter dictionary.
Implementations should accept the dictionary returned by
param_dict.- Parameters:
param_dict (dict) – Dictionary with image parameters.
mapper (MappingBase | None) – Mapping instance, defaults to
None.
- Returns:
Image model instance.
- Return type:
- Raises:
KeyError – If required keys are missing.
ValueError – If configuration values are invalid.
TypeError – If configuration values have incompatible types.
- abstract property type: ImageType#
Return the image model type.
- Returns:
Image type.
- Return type:
ImageType
- abstract property param_dict: dict#
Return image parameters as a dictionary.
The returned dictionary must be compatible with
from_dict().- Returns:
Image parameters.
- Return type:
dict
- abstract property is_geo_referenced: bool#
Return whether the image is geo-referenced.
- Returns:
Trueif geo-referenced (and mapping/projection can be computed), otherwiseFalse.- Return type:
bool
- abstract property center: tuple[float, float]#
Return the center of the image in pixel coordinates.
Implementations may define the center differently (e.g. the principal point for perspective cameras).
- Returns:
Center point (x, y) in pixel coordinates.
- Return type:
tuple[float, float]
- abstractmethod position_to_crs(crs_t: CRS) Vector3D | None[source]#
Return the image reference position in the target CRS.
- Parameters:
crs_t (CRS) – Target CRS.
- Returns:
Position in
crs_torNoneif unavailable.- Return type:
Vector3D | None
- Raises:
CoordinateTransformationError – If coordinate transformation fails.
- abstractmethod project(coordinates: ArrayNx3, crs_s: CRS | None = None, transformer: CoordinateTransformer | None = None) ProjectionResultSuccess | ResultFailure[Issue][source]#
Project 3D coordinates into image pixel coordinates.
- Parameters:
coordinates (ArrayNx3) – 3D coordinates to project.
crs_s (CRS | None) – CRS of the input coordinates, defaults to
None.transformer (CoordinateTransformer | None) – Optional coordinate transformer, defaults to
None.
- Returns:
Result of the projection.
- Return type:
ProjectionResult
- Raises:
CoordinateTransformationError – If coordinate transformation fails.
- abstractmethod map_center_point(mapper: MappingBase | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#
Map the image center pixel to 3D coordinates.
For perspective images this is typically the principal point.
- Parameters:
mapper (MappingBase | None) – Mapper to use, defaults to
None(usesmapper).transformer (CoordinateTransformer | None) – Optional coordinate transformer, defaults to
None.
- Returns:
Mapping result.
- Return type:
MappingResult
- Raises:
CoordinateTransformationError – If coordinate transformation fails.
- abstractmethod map_footprint(points_per_edge: int = 0, mapper: MappingBase | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#
Map footprint of image to 3D.
- Parameters:
points_per_edge (int) – The number of points inserted between corners, defaults to
0.0means only corner points are mapped.mapper (MappingBase | None) – Mapper to use, defaults to
None(usesmapper).transformer (CoordinateTransformer | None) – Optional coordinate transformer, defaults to
None.
- Returns:
Mapping result.
- Return type:
MappingResult
- Raises:
CoordinateTransformationError – If coordinate transformation fails.
- abstractmethod map_points(points_image: ArrayNx2 | ArrayNx3 | list[list[float]] | list[list[int]] | list[float] | list[int], mapper: MappingBase | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#
Map image pixel coordinates to 3D coordinates.
- Parameters:
points_image (ArrayNx2 | ArrayNx3 | list[list[float]] | list[list[int]] | list[float] | list[int]) – Pixel coordinates.
mapper (MappingBase | None) – Mapper to use, defaults to
None(usesmapper).transformer (CoordinateTransformer | None) – Optional coordinate transformer, defaults to
None.
- Returns:
Mapping result.
- Return type:
MappingResult
- Raises:
ValueError – If
points_imagecannot be parsed as an array of 2D points.NotGeoreferencedError – If the image is not geo-referenced.
MapperMissingError – If no mapper is available.
CRSInputError – If the mapper rejects CRS/transformer input.
CoordinateTransformationError – If coordinate transformation fails.
MappingBackendError – If the mapping backend fails unexpectedly.
WeitsichtError – Base class for all weitsicht exceptions. Catch this to handle any weitsicht error; catch specific subclasses first if you need to distinguish causes.
- property position_wgs84: tuple[float, float, float] | None#
4979) of the image or None if not possible. The position_to_crs method is defined by the class implementation.
- Returns:
Position in WGS84 (x, y, z) or
None.- Return type:
tuple[float, float, float] | None
- Raises:
CoordinateTransformationError – If coordinate transformation fails.
- Type:
Return the position in WGS84 (EPSG
- property position_wgs84_geojson: dict | None#
as a GeoJSON point.
- Returns:
GeoJSON
Pointmapping orNoneif the position is unavailable.- Return type:
dict | None
- Raises:
CoordinateTransformationError – If coordinate transformation fails.
- Type:
Return the image position in WGS84 (EPSG
- property crs: CRS | None#
Return the image world CRS.
- Returns:
CRS of the image or
Noneif unknown.- Return type:
CRS | None
- property crs_wkt: str | None#
Return images CRS as wkt string
- property crs_proj4: str | None#
Return images CRS as proj4 string
- property width: int#
Return width of image (column number)
- property height: int#
Return height of image (row number)
- property shape: tuple[int, int]#
Return shape of image as tuple(width, height)