RGBClassTransformer#

class RGBClassTransformer[source]#

Bases: RasterTransformer

Maps RGB values to class IDs. Can also do the reverse.

__init__(class_config: ClassConfig)[source]#
Parameters

class_config (ClassConfig) –

Methods

__init__(class_config)

class_to_rgb(class_labels)

get_out_channels(in_channels)

Number of channels in output of transform().

get_out_dtype(in_dtype)

dtype of the output of transform().

rgb_to_class(array_rgb)

transform(chip)

Transform RGB array to array of class IDs or vice versa.

__init__(class_config: ClassConfig)[source]#
Parameters

class_config (ClassConfig) –

class_to_rgb(class_labels: ndarray) ndarray[source]#
Parameters

class_labels (ndarray) –

Return type

ndarray

get_out_channels(in_channels: int) Literal[1][source]#

Number of channels in output of transform().

Parameters

in_channels (int) –

Return type

Literal[1]

get_out_dtype(in_dtype: dtype) dtype[source]#

dtype of the output of transform().

Parameters

in_dtype (dtype) –

Return type

dtype

rgb_to_class(array_rgb: ndarray) ndarray[source]#
Parameters

array_rgb (ndarray) –

Return type

ndarray

transform(chip: ndarray) ndarray[source]#

Transform RGB array to array of class IDs or vice versa.

Parameters

chip (ndarray) – Numpy array of shape (H, W, 3).

Returns

An array of class IDs of shape (H, W, 1).

Return type

ndarray