Image edge expansion with Python opencv


original image

According to the pixel value of the image boundary, expand the image outwards, and expand 50 pixels in each direction.

a = cv2.copyMakeBorder(img,50,50,50,50,cv2.BORDER_REPLICATE)

Turn 50 pixels close to the boundary out (axisymmetric):

a = cv2.copyMakeBorder(img,50,50,50,50,cv2.BORDER_REFLECT)

Constant fill:

a = cv2.copyMakeBorder(img,50,50,50,50, cv2.BORDER_CONSTANT,value=[0,255,0])

The above Python opencv implementation of image edge expansion is all the content shared by the editor. I hope it can give you a reference, and I hope you can support developer more.