SemanticSegmentationLabelSource#
- class SemanticSegmentationLabelSource[source]#
Bases:
LabelSource
A read-only label source for semantic segmentation.
Attributes
Bounding box applied to the source.
Extent of the
LabelSource
.- __init__(raster_source: RasterSource, class_config: ClassConfig, bbox: Optional[Box] = None)[source]#
Constructor.
- Parameters
raster_source (RasterSource) – A raster source that returns a single channel raster with class_ids as values.
null_class_id (int) – the null class id used as fill values for when windows go over the edge of the label array. This can be retrieved using class_config.null_class_id.
bbox (Optional[Box], optional) – User-specified crop of the extent. If None, the full extent available in the source file is used.
class_config (ClassConfig) –
Methods
__init__
(raster_source, class_config[, bbox])Constructor.
enough_target_pixels
(window, ...)Check if window contains enough pixels of the given target classes.
get_label_arr
([window])Get labels for a window.
get_labels
([window])Get labels for a window.
set_bbox
(bbox)Set self.extent to the given value.
- __init__(raster_source: RasterSource, class_config: ClassConfig, bbox: Optional[Box] = None)[source]#
Constructor.
- Parameters
raster_source (RasterSource) – A raster source that returns a single channel raster with class_ids as values.
null_class_id (int) – the null class id used as fill values for when windows go over the edge of the label array. This can be retrieved using class_config.null_class_id.
bbox (Optional[Box], optional) – User-specified crop of the extent. If None, the full extent available in the source file is used.
class_config (ClassConfig) –
- enough_target_pixels(window: Box, target_count_threshold: int, target_classes: List[int]) bool [source]#
Check if window contains enough pixels of the given target classes.
- Parameters
- Returns
True (the window does contain interesting pixels) or False.
- Return type
- get_label_arr(window: Optional[Box] = None) ndarray [source]#
Get labels for a window.
The returned array will be the same size as the input window. If window overflows the extent, the overflowing region will be filled with the ID of the null class as defined by the class_config.
- Parameters
window (Optional[Box], optional) – Window (in pixel coords) to get labels for. If None, returns a label array covering the full extent of the scene.
- Returns
Label array.
- Return type
np.ndarray
- get_labels(window: Optional[Box] = None) SemanticSegmentationLabels [source]#
Get labels for a window.
- Parameters
window (Optional[Box], optional) – Window to get labels for. If
None –
scene. (returns labels covering the full extent of the) –
- Returns
The labels.
- Return type
- set_bbox(bbox: Box) None [source]#
Set self.extent to the given value.
Note
This method is idempotent.
- property crs_transformer: CRSTransformer#