MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / pad_images

Method pad_images

PATH/core/augmentation.py:460–473  ·  view source on GitHub ↗
(self, img)

Source from the content-addressed store, hash-verified

458 self.contrast = contrast
459
460 def pad_images(self, img):
461 h, w = img.shape[:2]
462 width_max = w + 2 * self.padding_size
463 height_max = h + 2 * self.padding_size
464
465 diff_vert = height_max - h
466 pad_top = diff_vert//2
467 pad_bottom = diff_vert - pad_top
468 diff_hori = width_max - w
469 pad_left = diff_hori//2
470 pad_right = diff_hori - pad_left
471 img_padded = cv2.copyMakeBorder(img, pad_top, pad_bottom, pad_left, pad_right, cv2.BORDER_CONSTANT, value=0)
472 assert img_padded.shape[:2] == (height_max, width_max)
473 return img_padded
474
475 def random_crop(self, img):
476 h, w = img.shape[:2]

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected