how to add border around an image in opencv python

后端 未结 4 2117
清歌不尽
清歌不尽 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条回答
  •  我在风中等你
    2020-12-09 15:22

    Answer in one line

    outputImage = cv2.copyMakeBorder(
                     inputImage, 
                     topBorderWidth, 
                     bottomBorderWidth, 
                     leftBorderWidth, 
                     rightBorderWidth, 
                     cv2.BORDER_CONSTANT, 
                     value=color of border
                  )
    

提交回复
热议问题