博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数学之路-python计算实战(19)-机器视觉-卷积滤波
阅读量:5995 次
发布时间:2019-06-20

本文共 2182 字,大约阅读时间需要 7 分钟。

filter2D

Convolves an image with the kernel.

C++:
 void 
filter2D
(InputArray 
src, OutputArray 
dst, int 
ddepth, InputArray
kernel, Point 
anchor=Point(-1,-1), double 
delta=0, int 
borderType=BORDER_DEFAULT 
)
Python:
 
cv2.
filter2D
(src, ddepth, kernel
[, dst
[, anchor
[, delta
[, borderType
]
]
]
]
) → dst
C:
 void 
cvFilter2D
(const CvArr* 
src, CvArr* 
dst, const CvMat* 
kernel, CvPoint
anchor=cvPoint(-1,-1) 
)
Python:
 
cv.
Filter2D
(src, dst, kernel, anchor=(-1, -1)
) → None
Parameters:
  • src – input image.
  • dst – output image of the same size and the same number of channels as src.
  • ddepth –
    desired depth of the destination image; if it is negative, it will be the same as 
    src.depth(); the following combinations of
    src.depth() and 
    ddepth are supported:
    • src.depth() = CV_8Uddepth = -1/CV_16S/CV_32F/CV_64F
    • src.depth() = CV_16U/CV_16Sddepth = -1/CV_32F/CV_64F
    • src.depth() = CV_32Fddepth = -1/CV_32F/CV_64F
    • src.depth() = CV_64Fddepth = -1/CV_64F

    when ddepth=-1, the output image will have the same depth as the source.

  • kernel – convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using  and process them individually.
  • anchor – anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.
  • delta – optional value added to the filtered pixels before storing them in dst.
  • borderType – pixel extrapolation method (see for details).

The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode.

# -*- coding: utf-8 -*-   #卷积滤波#code:myhaspl@myhaspl.comimport cv2import numpy as npfn="test2.jpg"myimg=cv2.imread(fn)img=cv2.cvtColor(myimg,cv2.COLOR_BGR2GRAY)myh=np.array([[0,1,0],[1,-4,1],[0,1,0]])jgimg=cv2.filter2D(img,-1,myh)cv2.imshow('src',img)cv2.imshow('dst',jgimg)cv2.waitKey()cv2.destroyAllWindows()

本博客全部内容是原创,假设转载请注明来源

你可能感兴趣的文章
ProgressDialog使用总结
查看>>
安装完操作系统后,必备开发软件安装
查看>>
网络爬虫基本原理(一)
查看>>
让Win8自动登录免输入密码的小技巧
查看>>
RSA3:预提取数据
查看>>
MinGW 介绍
查看>>
注册域名到搜索引擎
查看>>
Eclipse中如何安装和使用GrepCode插件 (转)
查看>>
神经网络和机器学习、强人工智能
查看>>
JavaScript内部原理实践——真的懂JavaScript吗?(转)
查看>>
【DeepLearning】Exercise:Softmax Regression
查看>>
Android JNI入门第四篇——Android.mk文件分析
查看>>
Get a developer license for windows store app
查看>>
策略模式
查看>>
Android Studio导入第三方类库的方法
查看>>
zxing二维码
查看>>
.NET平台下的微信SDK(Rabbit.WeiXin)开源发布
查看>>
简要介绍如何集成Vitamio安卓版SDK
查看>>
BZOJ1107 : [POI2007]驾驶考试egz
查看>>
div与span区别及用法
查看>>