color

Functions

generate_rgb(exist_colors)

Generate new color which oppositely by exist colors.

get_predefined_colors(n)

hex2rgb(hex_value)

Convert HEX RGB string to integer RGB format.

random_rgb([fix_satlight])

Generate RGB color with fixed saturation and lightness.

rgb2hex(color)

Convert integer color format to HEX string.

validate_channel_value(value)

Generates ValueError if value not between 0 and 255.

Description

Color utilities.

generate_rgb(exist_colors)[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:
import supervisely as sly

exist_colors = [[0, 0, 0], [128, 64, 255]]
color = sly.color.generate_rgb(exist_colors)
print(color)
# Output: [15, 138, 39]
hex2rgb(hex_value)[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:
import supervisely as sly

hex_color = '#8040FF'
color = sly.color.hex2rgb(hex_color)
print(color)
# Output: [128, 64, 255]
random_rgb(fix_satlight=True)[source]

Generate RGB color with fixed saturation and lightness.

Returns:

RGB integer values

Return type:

List[int, int, int]

Usage Example:
import supervisely as sly

color = sly.color.random_rgb()
print(color)
# Output: [138, 15, 123]
rgb2hex(color)[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:
import supervisely as sly

hex_color = sly.color.rgb2hex([128, 64, 255])
print(hex_color)
# Output: #8040FF
validate_channel_value(value)[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:

None