SemanticSegmentationLabelSource#

class SemanticSegmentationLabelSource[source]#

Bases: LabelSource

A read-only label source for semantic segmentation.

Attributes

__init__(raster_source: RasterSource, class_config: ClassConfig)[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.

  • class_config (ClassConfig) –

Methods

__init__(raster_source, class_config)

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.

__init__(raster_source: RasterSource, class_config: ClassConfig)[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.

  • 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
  • window (Box) – The larger window from-which the sub-window will be clipped.

  • target_count_threshold (int) – Minimum number of target pixels.

  • target_classes (List[int]) – The classes of interest. The given window is examined to make sure that it contains a sufficient number of target pixels.

Returns

True (the window does contain interesting pixels) or False.

Return type

bool

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 to get labels for. If

  • None

  • scene. (returns a label array covering the full extent of the) –

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

SemanticSegmentationLabels

property extent: Box#