Skip to content

Instantly share code, notes, and snippets.

@Yuktha-Majella
Created October 26, 2021 15:14
Show Gist options
  • Save Yuktha-Majella/b8dc4d8611ae3ff13adc070a655c294c to your computer and use it in GitHub Desktop.
Save Yuktha-Majella/b8dc4d8611ae3ff13adc070a655c294c to your computer and use it in GitHub Desktop.
#Making Borders
import cv2
import numpy as np
BLUE = [255,0,0]
img = cv2.imread('C:\\Users\\Admin\\Downloads\\operations on images\\olympic_logo.png')
replicate = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_REPLICATE)
reflect = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_REFLECT)
reflect101 = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_REFLECT_101)
wrap = cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_WRAP)
constant= cv2.copyMakeBorder(img,10,10,10,10,cv2.BORDER_CONSTANT,value=BLUE)
vis1 = np.concatenate((reflect, constant, reflect101), axis=1)
vis2 = np.concatenate((replicate, wrap), axis=1)
cv2.imshow("Original Image", img)
cv2.imshow("REFLECT vs CONSTANT vs REFLECT_101 ", vis1)
cv2.imshow("REPLICATE vs WRAP", vis2)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment