pixano.features.utils.image
base64_to_image(base64_image)
Decode image from base64 to Pillow.
Expect the image to be formatted as "data:image/{image_format};base64,{base64}".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base64_image
|
str
|
Image as base64. |
required |
Returns:
Type | Description |
---|---|
Image
|
Pillow image. |
Source code in pixano/features/utils/image.py
binary_to_url(im_bytes)
depth_array_to_gray(depth, valid_start=0.2, valid_end=1, scale=1.0)
Encode depth array to gray levels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth
|
ndarray
|
Depth array |
required |
valid_start
|
float
|
Valid start. |
0.2
|
valid_end
|
float
|
Valid end. |
1
|
scale
|
float
|
Scale. |
1.0
|
Returns:
Type | Description |
---|---|
ndarray
|
Depth array in gray levels. |
Source code in pixano/features/utils/image.py
depth_file_to_binary(depth_path)
Encode depth file to RGB image in binary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_path
|
str
|
Depth file path. |
required |
Returns:
Type | Description |
---|---|
bytes
|
Depth file as RGB image in binary. |
Source code in pixano/features/utils/image.py
encode_rle(mask, height, width)
Encode mask from polygons / uncompressed RLE / RLE to RLE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
list[list] | dict
|
Mask as polygons / uncompressed RLE / RLE. |
required |
height
|
int
|
Image height. |
required |
width
|
int
|
Image width. |
required |
Returns:
Type | Description |
---|---|
dict
|
Mask as RLE. |
Source code in pixano/features/utils/image.py
get_image_thumbnail(image, size)
Get image thumbnail.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
Image
|
Pillow Image. |
required |
size
|
tuple[int, int]
|
Thumbnail size. |
required |
Returns:
Type | Description |
---|---|
Image
|
Image thumbnail as Pillow. |
Source code in pixano/features/utils/image.py
image_to_base64(image, format=None)
Encode image from Pillow to base64.
The image is returned as a base64 string formatted as "data:image/{image_format};base64,{base64}".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
Image
|
Pillow image. |
required |
format
|
str | None
|
Image format. |
None
|
Returns:
Type | Description |
---|---|
str
|
Image as base64. |
Source code in pixano/features/utils/image.py
image_to_binary(image, im_format='PNG')
Encode an image from Pillow to binary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
Image
|
Pillow image. |
required |
im_format
|
str
|
Image file extension. |
'PNG'
|
Returns:
Type | Description |
---|---|
bytes
|
Image as binary. |
Source code in pixano/features/utils/image.py
mask_to_polygons(mask)
Encode mask from NumPy array to polygons.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
ndarray
|
Mask as NumPy array |
required |
Returns:
Type | Description |
---|---|
Tuple
|
|
Source code in pixano/features/utils/image.py
mask_to_rle(mask)
polygons_to_rle(polygons, height, width)
rle_to_mask(rle)
rle_to_polygons(rle)
Encode mask from RLE to polygons.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rle
|
dict[str, list[int] | bytes]
|
Mask as RLE. |
required |
Returns:
Type | Description |
---|---|
list[list]
|
Mask as polygons. |
Source code in pixano/features/utils/image.py
rle_to_urle(rle)
Encode mask from RLE to uncompressed RLE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rle
|
dict[str, list[int] | bytes]
|
Mask as RLE. |
required |
Returns:
Type | Description |
---|---|
dict[str, list[int]]
|
Mask as uncompressed RLE. |