当前位置: 首页 > news >正文

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

空间滤波基础

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

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

一、线性滤波器

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函数:

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

相关文章:

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

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

如何在Django中使用django-crontab启动定时任务、关闭任务以及关闭指定任务

安装django-crontab包: pip install django-crontab 在Django项目的settings.py文件中,找到INSTALLED_APPS配置,并添加django_crontab到列表中: INSTALLED_APPS [ ... django_crontab,... ] 在settings.py文件的末尾,添加以下配置以设…...

mysql配置项整理

二、:mysql服务器参数 general 基础配置 datadir/var/lib/mysql #数据文件存放的目录 socket/var/lib/mysql/mysql.sock #mysql.socket表示server和client在同一台服务器,并且使用localhost进行连接,就会使用socket进行连接 pid_file/v…...

【KRouter】一个简单且轻量级的Kotlin Routing框架

【KRouter】一个简单且轻量级的Kotlin Routing框架 KRouter(Kotlin-Router)是一个简单而轻量级的Kotlin路由框架。 具体来说,KRouter是一个通过URI来发现接口实现类的框架。它的使用方式如下: val homeScreen KRouter.route&l…...

时间管理类书籍阅读笔记

背景 这段时间看了时间管理方面的书籍,大部分和早晨时间利用相关。之所以有了利用早晨时间的想法,是某天下班后,感觉很疲惫,什么都不想做,于是就打了一晚上游戏,然后第二天重复着这样的生活。 突然意识到…...

CSS文字居中对齐学习

CSS使用text-align属性设置文字对齐方式&#xff1b;text-align:center&#xff0c;这样就设置了文字居中对齐&#xff1b; <!DOCTYPE html> <html><head><meta charset"UTF-8"><title>css 水平居中</title><style>.box …...

《论文阅读》CARE:通过条件图生成的共情回复因果关系推理 EMNLP 2022

《论文阅读》CARE:通过条件图生成的移情反应因果关系推理 前言简介基础知识TransformerVariational Graph Auto-Encoder 变分图自编码器`邻接矩阵(adjacency matrix)``图神经网络(GNN)``图卷积神经网络(GCN)``自编码器(Auto Encoder)``图自编码器(GAE)``变分图自编码…...

React 开发一个移动端项目(1)

技术栈&#xff1a; 项目搭建&#xff1a;React 官方脚手架 create-react-appreact hooks状态管理&#xff1a;redux 、 redux-thunkUI 组件库&#xff1a;antd-mobileajax请求库&#xff1a;axios路由&#xff1a;react-router-dom 以及 historyCSS 预编译器&#xff1a;sass…...

c#查看代码的执行耗时( Stopwatch )

我们如果需要看某段代码的执行耗时&#xff0c;会通过如下的方式进行查看 using System.Diagnostics; private void button1_Click(object sender, EventArgs e){Stopwatch sw Stopwatch.StartNew();//sw.Start();StringBuilder sb new StringBuilder();for(int i 0; i <…...

Python网络爬虫库:轻松提取网页数据的利器

网络爬虫是一种自动化程序&#xff0c;它可以通过访问网页并提取所需的数据。Python是一种流行的编程语言&#xff0c;拥有许多强大的网络爬虫库。在本文中&#xff0c;我们将介绍几个常用的Python网络爬虫库以及它们的使用。 Requests库 Requests是一个简单而优雅的HTTP库&…...

YOLOv5算法改进(15)— 更换Neck之AFPN

前言&#xff1a;Hello大家好&#xff0c;我是小哥谈。在YOLOv5中添加AFPN&#xff08;Adaptive Feature Pyramid Network&#xff09;可以提高目标检测的准确性。AFPN是一种用于目标检测任务的功能增强模块&#xff0c;它能够自适应地融合来自不同层级的特征图&#xff0c;以提…...

Vue2项目练手——通用后台管理项目第七节

Vue2项目练手——通用后台管理项目 用户管理分页使用的组件Users.vuemock.js 关键字搜索区Users.vue 权限管理登录页面样式修改Login.vue 登录权限使用token对用户鉴&#xff0c;使用cookie对当前信息保存&#xff08;类似localstorage&#xff09;Login.vuerouter/index.js 登…...

《Web安全基础》04. 文件操作安全

web 1&#xff1a;文件操作安全2&#xff1a;文件上传漏洞2.1&#xff1a;简介2.2&#xff1a;防护与绕过2.3&#xff1a;WAF 绕过2.3.1&#xff1a;数据溢出2.3.2&#xff1a;符号变异2.3.3&#xff1a;数据截断2.3.4&#xff1a;重复数据 3&#xff1a;文件包含漏洞4&#xf…...

docker-compose安装nginx

基于docker-compose安装nginx 目录 一、目录结构 1、docker-compose.yml 2、nginx.conf 3、default.conf 4、index.html 二、访问测试 一、目录结构 1、docker-compose.yml version: 3 services:nginx:image: registry.cn-hangzhou.aliyuncs.com/zhengqing/nginx:1.21.1…...

报错处理:MySQL无法启动

报错环境&#xff1a; Linux MySQL 具体报错&#xff1a; Cant connect to local MySQL server through socket /var/run/mysqld/mysqld.sock 排错思路&#xff1a; 当尝试启动MySQL服务时&#xff0c;如果出现无法连接到MySQL服务的错误&#xff0c;可能是由于MySQL服务未正确…...

Vue中表单手机号验证与手机号归属地查询

下面是一篇关于Vue中如何进行表单手机号验证与手机号归属地查询的Markdown格式的文章&#xff0c;包含代码示例。 Vue中表单手机号验证与手机号归属地查询 手机号验证和归属地查询是许多Web应用程序中常见的功能之一。在Vue.js中&#xff0c;我们可以轻松地实现这两个功能。本…...

初高(重要的是高中)中数学知识点综合

1. 集合 1.1 集合的由来和确定性 确定对象构成的整体称为集合&#xff08;组成集合的元素必须是确定的 &#xff09;&#xff0c;每个集合内的对象个体成为元素(Element)。确定性&#xff1a; 给定一个集合&#xff0c;任何一个对象是不是这个集合内的元素&#xff0c;就已经确…...

Fiddler 系列教程(二) Composer创建和发送HTTP Request跟手机抓包

Fiddler Composer介绍 Composer的官方帮助文档&#xff1a;http://www.fiddler2.com/fiddler/help/composer.asp Fiddler的作者把HTTP Request发射器取名叫Composer(中文意思是&#xff1a;乐曲的创造者), 很有诗意 Fiddler Composer的功能就是用来创建HTTP Request 然后发送…...

淘宝平台开放接口API接口

淘宝平台开放接口API接口是指淘宝平台提供给第三方开发者的一组接口&#xff0c;用于实现与淘宝平台的数据交互和功能扩展。通过API接口&#xff0c;第三方开发者可以获取淘宝平台上的商品信息、订单信息、用户信息等数据&#xff0c;也可以实现商品的发布、订单的创建和支付等…...

缓存夺命连环问

1. 为什么要用缓存&#xff1f; 用缓存&#xff0c;主要有两个用途&#xff1a;高性能、高并发。 高性能 假设这么个场景&#xff0c;你有个操作&#xff0c;一个请求过来&#xff0c;吭哧吭哧你各种乱七八糟操作 MySQL&#xff0c;半天查出来一个结果&#xff0c;耗时 600m…...

React 第五十五节 Router 中 useAsyncError的使用详解

前言 useAsyncError 是 React Router v6.4 引入的一个钩子&#xff0c;用于处理异步操作&#xff08;如数据加载&#xff09;中的错误。下面我将详细解释其用途并提供代码示例。 一、useAsyncError 用途 处理异步错误&#xff1a;捕获在 loader 或 action 中发生的异步错误替…...

Linux 文件类型,目录与路径,文件与目录管理

文件类型 后面的字符表示文件类型标志 普通文件&#xff1a;-&#xff08;纯文本文件&#xff0c;二进制文件&#xff0c;数据格式文件&#xff09; 如文本文件、图片、程序文件等。 目录文件&#xff1a;d&#xff08;directory&#xff09; 用来存放其他文件或子目录。 设备…...

【OSG学习笔记】Day 18: 碰撞检测与物理交互

物理引擎&#xff08;Physics Engine&#xff09; 物理引擎 是一种通过计算机模拟物理规律&#xff08;如力学、碰撞、重力、流体动力学等&#xff09;的软件工具或库。 它的核心目标是在虚拟环境中逼真地模拟物体的运动和交互&#xff0c;广泛应用于 游戏开发、动画制作、虚…...

React Native 导航系统实战(React Navigation)

导航系统实战&#xff08;React Navigation&#xff09; React Navigation 是 React Native 应用中最常用的导航库之一&#xff0c;它提供了多种导航模式&#xff0c;如堆栈导航&#xff08;Stack Navigator&#xff09;、标签导航&#xff08;Tab Navigator&#xff09;和抽屉…...

逻辑回归:给不确定性划界的分类大师

想象你是一名医生。面对患者的检查报告&#xff08;肿瘤大小、血液指标&#xff09;&#xff0c;你需要做出一个**决定性判断**&#xff1a;恶性还是良性&#xff1f;这种“非黑即白”的抉择&#xff0c;正是**逻辑回归&#xff08;Logistic Regression&#xff09;** 的战场&a…...

STM32F4基本定时器使用和原理详解

STM32F4基本定时器使用和原理详解 前言如何确定定时器挂载在哪条时钟线上配置及使用方法参数配置PrescalerCounter ModeCounter Periodauto-reload preloadTrigger Event Selection 中断配置生成的代码及使用方法初始化代码基本定时器触发DCA或者ADC的代码讲解中断代码定时启动…...

大模型多显卡多服务器并行计算方法与实践指南

一、分布式训练概述 大规模语言模型的训练通常需要分布式计算技术,以解决单机资源不足的问题。分布式训练主要分为两种模式: 数据并行:将数据分片到不同设备,每个设备拥有完整的模型副本 模型并行:将模型分割到不同设备,每个设备处理部分模型计算 现代大模型训练通常结合…...

uniapp 开发ios, xcode 提交app store connect 和 testflight内测

uniapp 中配置 配置manifest 文档&#xff1a;manifest.json 应用配置 | uni-app官网 hbuilderx中本地打包 下载IOS最新SDK 开发环境 | uni小程序SDK hbulderx 版本号&#xff1a;4.66 对应的sdk版本 4.66 两者必须一致 本地打包的资源导入到SDK 导入资源 | uni小程序SDK …...

go 里面的指针

指针 在 Go 中&#xff0c;指针&#xff08;pointer&#xff09;是一个变量的内存地址&#xff0c;就像 C 语言那样&#xff1a; a : 10 p : &a // p 是一个指向 a 的指针 fmt.Println(*p) // 输出 10&#xff0c;通过指针解引用• &a 表示获取变量 a 的地址 p 表示…...

pycharm 设置环境出错

pycharm 设置环境出错 pycharm 新建项目&#xff0c;设置虚拟环境&#xff0c;出错 pycharm 出错 Cannot open Local Failed to start [powershell.exe, -NoExit, -ExecutionPolicy, Bypass, -File, C:\Program Files\JetBrains\PyCharm 2024.1.3\plugins\terminal\shell-int…...