import cv2
import numpy as np
from matplotlib import pyplot as plt

img1 =cv2.imread('opencvlogo.jpg')

#replicate = cv2.copyMakeBorder(img1,40,40,40,40,cv2.BORDER_REPLICATE)
#reflect = cv2.copyMakeBorder(img1,40,40,40,40,cv2.BORDER_REFLECT)
#reflect101 = cv2.copyMakeBorder(img1,40,40,40,40,cv2.BORDER_REFLECT_101)
#wrap = cv2.copyMakeBorder(img1,40,40,40,40,cv2.BORDER_WRAP)
print ( img1.shape)
imagee =img1[325:603, 352:560]
print(imagee.shape)
#plt.imshow( imagee,cmap='gray', interpolation='bicubic')
#plt.show()
conimg= cv2.copyMakeBorder(imagee,40,40,40,40,cv2.BORDER_CONSTANT,value=[0,255,0])
print(conimg.shape)
img1[285:643,312:600]=conimg
#cv2.imshow('conim',conimg)
#plt.imshow( conimg,cmap='gray', interpolation='bicubic')
#plt.show()
print(conimg.shape)
constant= cv2.copyMakeBorder(img1,40,40,40,40,cv2.BORDER_CONSTANT,value=[255,0,0])

#plt.subplot(231),plt.imshow(img1,'gray'),plt.title('ORIGINAL')
#plt.subplot(232),plt.imshow(replicate,'gray'),plt.title('REPLICATE')
#plt.subplot(233),plt.imshow(reflect,'gray'),plt.title('REFLECT')
#plt.subplot(234),plt.imshow(reflect101,'gray'),plt.title('REFLECT_101')
#plt.subplot(235),plt.imshow(wrap,'gray'),plt.title('WRAP')
#plt.subplot(236),plt.imshow(constant,'gray'),plt.title('CONSTANT')

plt.imshow( constant,cmap='gray', interpolation='bicubic')
plt.show()
