MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / add_margin

Function add_margin

transforms/joint_transforms.py:48–60  ·  view source on GitHub ↗

Add margin around an image top, right, bottom, left are the margin widths, in pixels margin_color is what to use for the margins

(pil_img, top, right, bottom, left, margin_color)

Source from the content-addressed store, hash-verified

46
47
48def add_margin(pil_img, top, right, bottom, left, margin_color):
49 """
50 Add margin around an image
51
52 top, right, bottom, left are the margin widths, in pixels
53 margin_color is what to use for the margins
54 """
55 width, height = pil_img.size
56 new_width = width + right + left
57 new_height = height + top + bottom
58 result = Image.new(pil_img.mode, (new_width, new_height), margin_color)
59 result.paste(pil_img, (left, top))
60 return result
61
62
63def set_crop_size(crop_size):

Callers 1

image_in_cropMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected