You can use:
image = cv2.copyMakeBorder(src, top, bottom, left, right, borderType)
Where src
is your source image and top
, bottom
, left
, right
are the padding around the image.
You can use max(sizes) – size value of the image in a while loop to add the padding to each image.
The bordertype can be one of these:
cv2.BORDER_CONSTANT
cv2.BORDER_REFLECT
cv2.BORDER_REFLECT_101
cv2.BORDER_DEFAULT
cv2.BORDER_REPLICATE
cv2.BORDER_WRAP