当前位置: 首页 > 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…...

Python爬虫实战:研究MechanicalSoup库相关技术

一、MechanicalSoup 库概述 1.1 库简介 MechanicalSoup 是一个 Python 库,专为自动化交互网站而设计。它结合了 requests 的 HTTP 请求能力和 BeautifulSoup 的 HTML 解析能力,提供了直观的 API,让我们可以像人类用户一样浏览网页、填写表单和提交请求。 1.2 主要功能特点…...

超短脉冲激光自聚焦效应

前言与目录 强激光引起自聚焦效应机理 超短脉冲激光在脆性材料内部加工时引起的自聚焦效应&#xff0c;这是一种非线性光学现象&#xff0c;主要涉及光学克尔效应和材料的非线性光学特性。 自聚焦效应可以产生局部的强光场&#xff0c;对材料产生非线性响应&#xff0c;可能…...

Appium+python自动化(十六)- ADB命令

简介 Android 调试桥(adb)是多种用途的工具&#xff0c;该工具可以帮助你你管理设备或模拟器 的状态。 adb ( Android Debug Bridge)是一个通用命令行工具&#xff0c;其允许您与模拟器实例或连接的 Android 设备进行通信。它可为各种设备操作提供便利&#xff0c;如安装和调试…...

mysql已经安装,但是通过rpm -q 没有找mysql相关的已安装包

文章目录 现象&#xff1a;mysql已经安装&#xff0c;但是通过rpm -q 没有找mysql相关的已安装包遇到 rpm 命令找不到已经安装的 MySQL 包时&#xff0c;可能是因为以下几个原因&#xff1a;1.MySQL 不是通过 RPM 包安装的2.RPM 数据库损坏3.使用了不同的包名或路径4.使用其他包…...

蓝桥杯3498 01串的熵

问题描述 对于一个长度为 23333333的 01 串, 如果其信息熵为 11625907.5798&#xff0c; 且 0 出现次数比 1 少, 那么这个 01 串中 0 出现了多少次? #include<iostream> #include<cmath> using namespace std;int n 23333333;int main() {//枚举 0 出现的次数//因…...

【VLNs篇】07:NavRL—在动态环境中学习安全飞行

项目内容论文标题NavRL: 在动态环境中学习安全飞行 (NavRL: Learning Safe Flight in Dynamic Environments)核心问题解决无人机在包含静态和动态障碍物的复杂环境中进行安全、高效自主导航的挑战&#xff0c;克服传统方法和现有强化学习方法的局限性。核心算法基于近端策略优化…...

Kafka入门-生产者

生产者 生产者发送流程&#xff1a; 延迟时间为0ms时&#xff0c;也就意味着每当有数据就会直接发送 异步发送API 异步发送和同步发送的不同在于&#xff1a;异步发送不需要等待结果&#xff0c;同步发送必须等待结果才能进行下一步发送。 普通异步发送 首先导入所需的k…...

宇树科技,改名了!

提到国内具身智能和机器人领域的代表企业&#xff0c;那宇树科技&#xff08;Unitree&#xff09;必须名列其榜。 最近&#xff0c;宇树科技的一项新变动消息在业界引发了不少关注和讨论&#xff0c;即&#xff1a; 宇树向其合作伙伴发布了一封公司名称变更函称&#xff0c;因…...

Git常用命令完全指南:从入门到精通

Git常用命令完全指南&#xff1a;从入门到精通 一、基础配置命令 1. 用户信息配置 # 设置全局用户名 git config --global user.name "你的名字"# 设置全局邮箱 git config --global user.email "你的邮箱example.com"# 查看所有配置 git config --list…...

【前端异常】JavaScript错误处理:分析 Uncaught (in promise) error

在前端开发中&#xff0c;JavaScript 异常是不可避免的。随着现代前端应用越来越多地使用异步操作&#xff08;如 Promise、async/await 等&#xff09;&#xff0c;开发者常常会遇到 Uncaught (in promise) error 错误。这个错误是由于未正确处理 Promise 的拒绝&#xff08;r…...