how to add border around an image in opencv python

后端 未结 4 2100
清歌不尽
清歌不尽 2020-12-09 15:06

If I have an image like below, how can I add border all around the image such that the overall height and width of the final image increases but the height and width of the

4条回答
  •  -上瘾入骨i
    2020-12-09 15:37

    Add border using openCV

    import cv2
    white = [255,255,255]
    img1 = cv2.imread('input.png')
    constant= cv2.copyMakeBorder(img1,20,20,20,20,cv2.BORDER_CONSTANT,value=white)
    cv2.imwrite('output.png',constant)
    

提交回复
热议问题