标签:
关于border的部分,边缘处理。
# -*- coding: utf-8 -*- """ Created on Wed Sep 28 00:58:51 2016 @author: Administrator """ # making borders for image # cv2.copyMakeBorder() import cv2 import numpy as np from matplotlib import pyplot as plt BLUE = [255,0,0] img1 = cv2.imread(‘opencv_logo.png‘) replicate = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_REPLICATE) reflect = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_REFLECT) reflect101 = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_REFLECT_101) wrap = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_WRAP) constant = cv2.copyMakeBorder(img1,10,10,10,10,cv2.BORDER_CONSTANT,value=BLUE) 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(‘REFLECT101‘) plt.subplot(235),plt.imshow(wrap,‘gray‘),plt.title(‘WRAP‘) plt.subplot(236),plt.imshow(constant,‘gray‘),plt.title(‘CONSTANT‘) plt.show()
输出如下:
标签:
原文地址:http://www.cnblogs.com/buzhizhitong/p/5918483.html