Manage white borders
fill_with_white(im, image_ratio)
Fills an image with white such that it respects a wanted ratio
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im |
Image
|
Image to be processed |
required |
Kwargs: image_ratio (float): Wanted image ratio Returns: Image: Transformed image
Source code in template_vision/preprocessing/manage_white_borders.py
remove_white_borders(images, image_ratio_strategy=None, image_ratio=0.75, with_rotation=True)
Removes white border Also change the image ratio and rotate (if wanted) along largest dim. (i.e. portrait mode)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images |
list
|
Images to be processed |
required |
Kwargs: image_ratio_strategy (str): wanted strategy to apply new image_ratio - None: no change in image ratio - 'fill': add white borders on the smallest dimension - 'stretch': stretch the images such that they have the wanted ratio image_ratio (float): Wanted final image ratio (unused if image_ratio_strategy is None) with_rotation (bool): If the images must be rotated along largest dim. (i.e. portrait mode) Raises: ValueError: If image_ratio_strategy value is not a valid option ([None, 'fill', 'stretch']) Returns: list: Images sans les marges blanches
Source code in template_vision/preprocessing/manage_white_borders.py
rotate_image_largest_dim(im)
Rotates an image along largest dim. (i.e. portrait mode)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im |
Image
|
Image to be processed |
required |
Returns: Image: Rotated image
Source code in template_vision/preprocessing/manage_white_borders.py
stretch_image(im, image_ratio)
Stretch an image such that it respects a wanted ratio
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im |
Image
|
Image to be processed |
required |
Kwargs: image_ratio (float): Wanted image ratio Returns: Image: Transformed image