Color

supervisely_lib.imaging.color.random_rgb() → List[int, int, int][source]

Generate RGB color with fixed saturation and lightness.

Returns

RGB integer values

Return type

List[int, int, int]

Usage example
color = sly.color.random_rgb()
print(color)
# Output: [138, 15, 123]
supervisely_lib.imaging.color.generate_rgb(exist_colors: list) → List[int, int, int][source]

Generate new color which oppositely by exist colors.

Parameters

exist_colors (list) – List of existing colors in RGB format.

Returns

RGB integer values

Return type

List[int, int, int]

Usage example
exist_colors = [[0, 0, 0], [128, 64, 255]]
color = sly.color.generate_rgb(exist_colors)
print(color)
# Output: [15, 138, 39]
supervisely_lib.imaging.color.rgb2hex(color: List[int, int, int]) → str[source]

Convert integer color format to HEX string.

Parameters

color (List[int, int, int]) – List of existing colors in RGB format.

Returns

HEX RGB string

Return type

str

Usage example
hex_color = sly.color.rgb2hex([128, 64, 255])
print(hex_color)
# Output: #8040FF
supervisely_lib.imaging.color.hex2rgb(hex_value: str) → List[int, int, int][source]

Convert HEX RGB string to integer RGB format.

Parameters

hex_value (str) – HEX RGB string.

Returns

RGB integer values

Return type

List[int, int, int]

Usage example
hex_color = '#8040FF'
color = sly.color.hex2rgb(hex_color)
print(color)
# Output: [128, 64, 255]
supervisely_lib.imaging.color.validate_channel_value(value: int) → None[source]

Generates ValueError if value not between 0 and 255.

Parameters

value (int) – Input channel value.

Raises

ValueError if value not between 0 and 255.

Returns

None

Return type

NoneType