1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| """ 作者:Mibbp 日期: 2022年01月04日 """ import cv2 as cv import numpy as np import matplotlib.pyplot as plt
def cv_show (name,img): cv.imshow(name,img) cv.waitKey(0) cv.destroyAllWindows()
img = cv.imread('01.jpg')
top_size,bottom_size,left_size,right_size=(50,50,50,50)
replicate =cv.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,cv.BORDER_REPLICATE) cv_show('rep',replicate)
reflect =cv.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,cv.BORDER_REFLECT) cv_show('ref',reflect)
reflect101 =cv.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,cv.BORDER_REFLECT_101) cv_show('ref101',reflect101)
wrap =cv.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,cv.BORDER_WRAP) cv_show('wrap',wrap)
con =cv.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,cv.BORDER_CONSTANT,10) cv_show('con',con)
|