OpenCV
qq_41950131
这个作者很懒,什么都没留下…
展开
-
opencv模块
opencv下有2个文件build和sourcessources下的modules各个模块core:数据结构及其基本运算highgui:图像读取、显示、存储等UI接口imgproc:图像处理基本方法:几何变换、平滑、阈值分割、形态学处理、边缘检测、频率域处理features2d和nonfree:提取图像特征,nonfree实现一些专利算法,sift特征objdetect:目标...原创 2019-06-20 11:48:47 · 114 阅读 · 0 评论 -
自适应阈值
opencv提供函数:#自适应阈值import sys,cv2,mathimport numpy as npimport matplotlib.pyplot as pltdef adaptiveThresh(I,winSize,ratio=0.15): #均值平滑 I_mean = cv2.boxFilter(I,cv2.CV_32FC1,winSize) ...翻译 2019-07-10 10:44:41 · 1491 阅读 · 0 评论 -
2图像增强直方图均衡化
直方图均衡化#直方图均衡化#1计算图像的灰度直方图#2计算灰度直方图的累加直方图#3根据原理得到输入灰度级和输出灰度级之间的映射关系#4输出图像的每一个像素的灰度级import cv2,sys,mathimport numpy as npdef calcGrayHist(image): rows,cols = image.shape grayHist = np.ze...翻译 2019-06-24 19:34:04 · 293 阅读 · 0 评论 -
投影变换
import numpy as npimport cv2,sysimage = cv2.imread(‘E:\sy2\3\img.jpg’,cv2.IMREAD_GRAYSCALE)h,w = image.shapesrc = np.array([[0,0],[w-1,0],[0,h-1],[w-1,h-1]],np.float32)dst = np.array([[50,50],[w...翻译 2019-06-21 21:26:56 · 221 阅读 · 0 评论 -
图像增强
灰度直方图#灰度直方图import sys,cv2import numpy as npimport matplotlib.pyplot as pltdef calcGrayHist(image): rows,cols = image.shape grayHist = np.zeros([256],np.uint64) for r in range(rows): ...翻译 2019-06-23 22:21:22 · 128 阅读 · 0 评论 -
opencv图像转换
获取仿射矩阵方程法:cv2.getAffineTransform(src,dst)参数:src:二维矩阵,3对原始坐标,必须floatdst:二维矩阵,3对转换坐标,必须float矩阵法:cv2.getRotationMatrix2D(center,angle,scale)中心坐标,角度,缩放比例cv2.warpAffine(src, M, dsize[, dst[, flags...翻译 2019-06-21 17:50:27 · 209 阅读 · 0 评论 -
二值图的逻辑运算
#二值图的逻辑运算#opencv提供bitwise_and和bitwise_orimport cv2import numpy as np#**二维数组src1 = np.array([[255,0,255]])src2 = np.array([[255,0,0]])#与运算dst_and = cv2.bitwise_and(src1,src2)#或运算dst_or = cv2....翻译 2019-07-10 20:44:31 · 877 阅读 · 0 评论 -
均值平滑
#均值平滑#先积分,上,左边界补0,省去判断边界的问题import numpy as npfrom scipy import signalimport cv2def integral(image): rows,cols = image.shape #行积分运算 inteImagec = np.zeros((rows,cols),np.float32) fo...翻译 2019-07-05 17:38:50 · 2678 阅读 · 0 评论 -
中值平滑
书中代码感觉有错误,理解的可以交流#中值平滑,去除椒盐噪声,同时边缘锐利较好。如果取最大最小值相当于形态学#添加椒盐噪声import numpy as npfrom scipy import signalimport cv2def salt(image,number): rows,cols = image.shape saltImage = np.copy(image)...原创 2019-07-06 12:23:44 · 1200 阅读 · 0 评论 -
形态学处理膨胀
#形态学处理膨胀import sys,cv2,mathimport numpy as npimport matplotlib.pyplot as pltif __name__ == '__main__': I = cv2.imread('E:/sy2/6/img7.jpg',cv2.IMREAD_GRAYSCALE) cv2.imshow('I',I) #结构元半径...翻译 2019-07-11 14:33:01 · 297 阅读 · 0 评论 -
形态学处理腐蚀
opencv提供函数#形态学处理腐蚀import sys,cv2,mathimport numpy as npimport matplotlib.pyplot as pltdef calcGrayHist(image):rows,cols = image.shapegrayHist = np.zeros([256],np.uint64)for r in range(rows...翻译 2019-07-11 14:46:16 · 359 阅读 · 0 评论 -
otsu阈值分割
#otsu阈值分割import sys,cv2,mathimport numpy as npimport matplotlib.pyplot as pltdef calcGrayHist(image): rows,cols = image.shape grayHist = np.zeros([256],np.uint64) for r in range(rows):...翻译 2019-07-09 22:40:12 · 388 阅读 · 0 评论 -
高斯核函数
参考链接转载 2019-06-27 22:51:08 · 1141 阅读 · 0 评论 -
图像变换计算仿射矩阵
方程法:6个参数需要3对坐标import CV2import numpy as npsrc = np.array([[0,0],[200,0],[0,200]],np.float32)#原坐标,floatdst = np.array([[0,0],[100,0],[0,100]],np.float32)#变换后坐标floatA = cv2.getAffineTransform(src,...翻译 2019-06-21 11:59:19 · 1135 阅读 · 0 评论 -
opencv路径错误
最近处理图像,出现下面错误,查了一下,发现这种错误就是路径错误,需要检查路径。1、\与/2、图片后缀3、出现中文cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:352: error: (-215:Assertion failed) size.width>0...原创 2019-07-08 10:52:57 · 828 阅读 · 0 评论 -
双边滤波
#空间距离权重模板import numpy as npfrom scipy import signalimport cv2,mathdef getClosenessWeight(sigma_g,H,W): r,c = np.mgrid[0:H:1,0:W:1] r=r.astype(np.float64) c=c.astype(np.float64) pr...原创 2019-07-08 11:07:07 · 422 阅读 · 1 评论 -
联合双边滤波
#联合双边滤波#图像高斯平滑,近似性权重由高斯平滑后确定import numpy as npfrom scipy import signalimport cv2,mathdef getClosenessWeight(sigma_g,H,W): r,c = np.mgrid[0:H:1,0:W:1] r=r.astype(np.float64) c=c.astype...翻译 2019-07-08 12:52:21 · 1631 阅读 · 0 评论 -
opencv边界填充
#边界扩充import cv2import numpy as npsrc = cv2.imread('E:\\sy2\\4\\1.jpg',cv2.IMREAD_COLOR)dst1 = cv2.copyMakeBorder(src,20,20,20,20,cv2.BORDER_REFLECT_101)dst2 = cv2.copyMakeBorder(src,20,20,20,20,c...翻译 2019-06-27 15:42:29 · 313 阅读 · 0 评论 -
导向滤波
#导向滤波#细节增强,变暗,可以进行拉伸import numpy as npfrom scipy import signalimport cv2def integral(image): rows,cols = image.shape #行积分运算 inteImagec = np.zeros((rows,cols),np.float32) for r in ...翻译 2019-07-08 16:36:25 · 328 阅读 · 0 评论 -
阈值分割
#阈值分割:全局和局部阈值分割#主要阈值的选取import numpy as npimport cv2src = np.array([[123,234,68], [33,51,17], [48,98,234], [129,89,27], [45,167,134]]...翻译 2019-07-08 18:36:57 · 169 阅读 · 0 评论 -
直方图技术求阈值
#直方图技术import sys,cv2import numpy as npimport matplotlib.pyplot as pltdef calcGrayHist(image): rows,cols = image.shape grayHist = np.zeros([256],np.uint64) for r in range(rows): ...翻译 2019-07-09 10:34:51 · 1607 阅读 · 1 评论 -
熵算法阈值
#熵算法阈值import sys,cv2,mathimport numpy as npimport matplotlib.pyplot as pltdef calcGrayHist(image): rows,cols = image.shape grayHist = np.zeros([256],np.uint64) for r in range(rows): ...翻译 2019-07-09 20:46:17 · 729 阅读 · 0 评论 -
卷积
opencv中未有直接计算卷积运算函数实现same卷积1、flip函数卷积核逆时针翻转1802、filter2D添加链接描述http://www.mamicode.com/info-detail-909563.html转载 2019-06-27 21:10:26 · 123 阅读 · 0 评论 -
形态学开闭运算
#形态学开闭运算import sys,cv2,mathimport numpy as npimport matplotlib.pyplot as pltif __name__ == '__main__': I = cv2.imread('E:/sy2/7/img1.jpg',cv2.IMREAD_GRAYSCALE) cv2.imshow('I',I) #结构...翻译 2019-07-11 17:13:22 · 757 阅读 · 0 评论