更新时间:2023-09-20 09:07:40
你可以使用:
image = cv2.copyMakeBorder(src, top, bottom, left, right, borderType)
src
是你的源图片,top
、bottom
、left
、right
是图像周围的填充.
Where src
is your source image and top
, bottom
, left
, right
are the padding around the image.
您可以在 while 循环中使用 max(sizes) - 图像的大小值来为每个图像添加填充.边框类型可以是以下之一:
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