首页 > 代码库 > Python OpenCV —— Border

Python OpenCV —— Border

  关于border的部分,边缘处理。

# -*- coding: utf-8 -*-"""Created on Wed Sep 28 00:58:51 2016@author: Administrator"""# making borders for image# cv2.copyMakeBorder()import cv2import numpy as npfrom matplotlib import pyplot as pltBLUE = [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=http://www.mamicode.com/BLUE)>

  输出如下:

技术分享

 

Python OpenCV —— Border