<图像处理> 空间滤波基础

这篇具有很好参考价值的文章主要介绍了<图像处理> 空间滤波基础。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

空间滤波基础

图像滤波是一种常见的图像处理技术,用于平滑图像、去除噪音和边缘检测等任务。图像滤波的基本原理是在进行卷积操作时,通过把每个像素的值替换为该像素及其邻域的设定的函数值来修改图像。

预备知识:可分离滤波核、边缘填充。

一、线性滤波器

1、盒式滤波器(方框滤波器)
盒式核是最简单的低通滤波器核。盒式核中各像素点的系数相同(通常为1)。盒式滤波器因为也满足秩为1,所以也是可分离核,计算也可使用分离核进行加速。
K = α [ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ] 当 α = { 1 k s i z e . w i d t h ∗ k s i z e . h e i g h t if  n o r m a l i z e = t r u e 1 if 其他 K=\alpha \begin{bmatrix} 1 & 1 & 1& 1& 1\\ 1 & 1& 1& 1& 1\\ 1 & 1& 1& 1& 1\\ 1 & 1& 1& 1& 1\\ 1 & 1& 1& 1& 1\\ \end{bmatrix} 当\alpha=\begin{cases} \frac{1}{ksize.width*ksize.height} &\text{if } normalize = true \\ 1 &\text{if } 其他 \end{cases} K=α 1111111111111111111111111 α={ksize.widthksize.height11if normalize=trueif 其他

OpenCV函数:文章来源地址https://www.toymoban.com/news/detail-706213.html

void cv::boxFilter(InputArray src, OutputArray dst, int ddepth, Size ksize, Point anchor = Point(-1,-1), bool normalize = true, int borderType = BORDER_DEFAULT)

Parameters
src				input image.
dst				output image of the same size and type as src.
ddepth			the output image depth (-1 to use src.depth()).
ksize			blurring kernel size.
anchor			anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
normalize		flag, specifying whether the kernel is normalized by its area or not.
borderType		border mode used to extrapolate pixels outside of the image, see BorderTypes. BORDER_WRAP is not supported.

2、均值滤波器
均值滤波器是特殊的盒式滤波器,目标图像中的每个值都是源图像中相应位置一个窗口(核)中像素的平均值。
K = 1 k s i z e . w i d t h ∗ k s i z e . h e i g h t [ 1 1 1 . . . 1 1 1 1 1 . . . 1 1 . . . 1 1 1 . . . 1 1 ] K= \frac{1}{ksize.width*ksize.height} \begin{bmatrix} 1 & 1 & 1& ... & 1 & 1\\ 1 & 1& 1& ... & 1& 1\\ ...\\ 1 & 1& 1& ...& 1& 1\\ \end{bmatrix} K=ksize.widthksize.height1 11...1111111.........111111
OpenCV函数:

void cv::blur(InputArray src, OutputArray dst, Size ksize, Point anchor = Point(-1,-1), int borderType = BORDER_DEFAULT)	

Parameters
src				input image; it can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst				output image of the same size and type as src.
ksize			blurring kernel size.
anchor			anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
borderType		border mode used to extrapolate pixels outside of the image, see BorderTypes. BORDER_WRAP is not supported.

3、高斯滤波器
高斯滤波器是通过根据高斯函数来选择权值的线性平滑滤波器的方式,对随机分布和服从正态分布的噪声有很好地滤除效果。高斯滤波器比盒式滤波器产生的边缘更加平滑,因为高斯滤波器的权重服从二维高斯分布,越靠近窗口中心点权重越大。
高斯核公式:
k ( s , t ) = K e − s 2 + t 2 2 σ 2 k(s,t)=Ke^{-\frac{s^2+t^2}{2\sigma^2}} k(s,t)=Ke2σ2s2+t2

OpenCV函数:

void cv::GaussianBlur(InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY = 0, int borderType = BORDER_DEFAULT)	

Parameters
src				input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst				output image of the same size and type as src.
ksize			Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma.
sigmaX			Gaussian kernel standard deviation in X direction.
sigmaY			Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively (see getGaussianKernel for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY.
borderType		pixel extrapolation method, see BorderTypes. BORDER_WRAP is not supported.

二、非线性滤波器

1、中值滤波器
中值滤波器用中心像素的邻域内的灰度值的中值替换中心像素的值。中值滤波器对冲激噪声(椒盐噪声)特别有效,并且对图像的模糊程度比线性平滑滤波器要小得多。

OpenCV函数:

void cv::medianBlur(InputArray src, OutputArray dst, int ksize)	

Parameters
src				input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U.
dst				destination array of the same size and type as src.
ksize			aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...

2、双边滤波器
双边滤波器可以很好地减少不必要的噪声,同时保持边缘相当锐利。然而,与大多数过滤器相比,它非常慢。

OpenCV函数:

void cv::bilateralFilter(InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType = BORDER_DEFAULT)	

parameters
src				Source 8-bit or floating-point, 1-channel or 3-channel image.
dst				Destination image of the same size and type as src .
d				Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.
sigmaColor		Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color.
sigmaSpace		Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace.
borderType		border mode used to extrapolate pixels outside of the image, see BorderTypes

到了这里,关于<图像处理> 空间滤波基础的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【课程介绍】OpenCV 基础入门教程:图像读取、显示、保存,图像处理和增强(如滤波、边缘检测、图像变换),特征提取和匹配,目标检测和跟踪

    [ 专栏推荐 ] 😃 《视觉探索: OpenCV 基础入门教程》 😄 ❤️【简介】: Opencv 入门课程适合初学者,旨在介绍 Opencv 库的基础知识和核心功能。课程包括图像读取、显示、保存,图像处理和增强(如滤波、边缘检测、图像变换),特征提取和匹配,目标检测和跟踪等内容。学

    2024年02月16日
    浏览(40)
  • 数字图像处理之matlab实验(三):空间滤波器

    空间滤波,就是在原图像上,用一个固定尺寸的模板去做卷积运算,得到的新图像就是滤波结果。滤波,就是过滤某种信号的意思。过滤哪种信号取决于模板设计,如果是锐化模板,处理后就保留高频信号,如果是平滑模板,处理后就保留低频信号。 (1)模板运算 图像处理

    2024年04月28日
    浏览(36)
  • python --opencv图像处理滤波详解(均值滤波、2D 图像卷积、方框滤波、 高斯滤波、中值滤波、双边滤波)

    第一件事情还是先做名词解释,图像平滑到底是个啥? 从字面意思理解貌似图像平滑好像是在说图像滑动。 emmmmmmmmmmmmmmm。。。。 其实半毛钱关系也没有,图像平滑技术通常也被成为图像滤波技术(这个名字看到可能大家会有点感觉)。 每一幅图像都包含某种程度的噪声,

    2024年02月04日
    浏览(36)
  • (数字图像处理MATLAB+Python)第六章图像平滑-第一节:图像平滑概述和空间域平滑滤波

    图像平滑(Image Smoothing) :是一种数字图像处理技术,用于减少图像中的 噪声 和 不规则性 ,使图像更加平滑和连续。在图像中,噪声通常表现为不规则的、突出的像素值,这可能会导致图像细节丢失,使其难以进行分析和处理。图像平滑技术可以通过对像素值进行滤波来

    2023年04月24日
    浏览(29)
  • 图像处理--OpenCV实现图像加噪与滤波

    前言: Hello大家好,我是Dream。 今天来学习一下如何使用OpenCV实现图像加噪与滤波,欢迎大家一起参与探讨交流~ 编写一Python程序,要求实现以下功能: 读入一幅图像。 使用两种以上的方法分别向图像中添加噪声。 输出一幅二值图像,图像中未加入噪声的区域为黑色,加入

    2024年02月03日
    浏览(30)
  • 【图像处理OpenCV(C++版)】——5.5 图像平滑之双边滤波

    前言 : 😊😊😊 欢迎来到本博客 😊😊😊 🌟🌟🌟 本专栏主要结合OpenCV和C++来实现一些基本的图像处理算法并详细解释各参数含义,适用于平时学习、工作快速查询等,随时更新。 😊😊😊 具体食用方式:可以点击本专栏【OpenCV快速查找(更新中)】–搜索你要查询的算子

    2024年02月13日
    浏览(30)
  • 【OpenCV • c++】图像平滑处理(1) —— 线性滤波

      平滑处理也称为模糊处理,是一种简单且使用频率很高的图像处理方法,平滑处理的用途有很多,最常见的是用来减少图像上的噪点或者失真。在涉及到降低图像分辨率时,平滑处理是非常好用的方法。   图像滤波指的是在尽量保留图像细节特征的条件下对图像的噪音

    2024年03月20日
    浏览(36)
  • 【图像处理OpenCV(C++版)】——5.4 图像平滑之中值平滑(滤波)

    前言 : 😊😊😊 欢迎来到本博客 😊😊😊 🌟🌟🌟 本专栏主要结合OpenCV和C++来实现一些基本的图像处理算法并详细解释各参数含义,适用于平时学习、工作快速查询等,随时更新。 😊😊😊 具体食用方式:可以点击本专栏【OpenCV快速查找(更新中)】–搜索你要查询的算子

    2024年02月10日
    浏览(27)
  • 【图像处理OpenCV(C++版)】——5.3 图像平滑之均值平滑(滤波)

    前言 : 😊😊😊 欢迎来到本博客 😊😊😊 🌟🌟🌟 本专栏主要结合OpenCV和C++来实现一些基本的图像处理算法并详细解释各参数含义,适用于平时学习、工作快速查询等,随时更新。 😊😊😊 具体食用方式:可以点击本专栏【OpenCV快速查找(更新中)】–搜索你要查询的算子

    2024年02月04日
    浏览(35)
  • OpenCV(图像处理)-基于Oython-滤波器(低通、高通滤波器的使用方法)

    低通滤波 :低通滤波可以去除图像的噪音或平滑图像。 高通滤波 :可以帮助查找图像的边缘。 噪音 :即对一幅图像的产生负面效果,过暗或过亮的部分,一幅图像中,低于或高于某个像素点的值,都可以认为是噪音。 卷积核 :即用来滤波的矩阵,卷积核一般为奇数,如

    2024年02月09日
    浏览(42)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包