ReclassTransformer#

class ReclassTransformer[source]#

Bases: RasterTransformer

Maps class IDs in a label raster to other values.

__init__(mapping: dict[int, int])[source]#

Constructor.

Parameters:

mapping (dict[int, int]) – Remapping dictionary, value_from–>value_to.

Methods

__init__(mapping)

Constructor.

get_out_channels(in_channels)

Number of channels in output of transform().

get_out_dtype(in_dtype)

dtype of the output of transform().

transform(chip)

Reclassify a label raster using the given mapping.

__init__(mapping: dict[int, int])[source]#

Constructor.

Parameters:

mapping (dict[int, int]) – Remapping dictionary, value_from–>value_to.

get_out_channels(in_channels: int) int#

Number of channels in output of transform().

Parameters:

in_channels (int) –

Return type:

int

get_out_dtype(in_dtype: dtype) dtype#

dtype of the output of transform().

Parameters:

in_dtype (dtype) –

Return type:

dtype

transform(chip: np.ndarray)[source]#

Reclassify a label raster using the given mapping.

Parameters:

chip (np.ndarray) – Array of shape (…, H, W, C).

Returns:

Array of shape (…, H, W, C)