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

建设路第3小学网站电话国家企业信用信息查询全国

建设路第3小学网站电话,国家企业信用信息查询全国,企业网站建设实训心得,做网站建设多少钱空间滤波基础二:锐化 锐化的作用的突出灰度中的过渡。图像锐化通过空间微分来实现,微分将增强边缘和其他不连续(噪声),不强化灰度变化缓慢的区域。图像锐化也叫做高通滤波,通过高频,抑制低频。…

空间滤波基础二:锐化

锐化的作用的突出灰度中的过渡。图像锐化通过空间微分来实现,微分将增强边缘和其他不连续(噪声),不强化灰度变化缓慢的区域。图像锐化也叫做高通滤波,通过高频,抑制低频。

1、二阶导数锐化

f ( x ) f(x) f(x)的二阶导数定义为差分
∂ 2 f ∂ x 2 = f ( x + 1 ) + f ( x − 1 ) − 2 f ( x ) \frac{\partial^2f}{\partial x^2}=f(x+1)+f(x-1)-2f(x) x22f=f(x+1)+f(x1)2f(x)

拉普拉斯滤波器

最简单的各向同性二阶导数核是拉普拉斯核,对于图像 f ( x , y ) f(x,y) f(x,y),其定义如下:
∇ 2 f = ∂ 2 f ∂ x 2 + ∂ 2 f ∂ y 2 \nabla^2 f=\frac{\partial^2f}{\partial x^2}+\frac{\partial^2f}{\partial y^2} 2f=x22f+y22f
由于任意阶的导数都是线性算子,所以拉普拉斯也是线性算子。如下是对上式的 x 、 y x、y xy两个方向的离散化:
x x x方向:
∂ 2 f ∂ x 2 = f ( x + 1 , y ) + f ( x − 1 , y ) − 2 f ( x , y ) \frac{\partial^2f}{\partial x^2}=f(x+1,y)+f(x-1,y)-2f(x,y) x22f=f(x+1,y)+f(x1,y)2f(x,y)
y y y方向:
∂ 2 f ∂ y 2 = f ( x , y + 1 ) + f ( x , y − 1 ) − 2 f ( x , y ) \frac{\partial^2f}{\partial y^2}=f(x,y+1)+f(x,y-1)-2f(x,y) y22f=f(x,y+1)+f(x,y1)2f(x,y)
由上面三个公式可得,
∇ 2 f = f ( x + 1 , y ) + f ( x − 1 , y ) + f ( x , y + 1 ) + f ( x , y − 1 ) − 4 f ( x , y ) \nabla^2 f=f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)-4f(x,y) 2f=f(x+1,y)+f(x1,y)+f(x,y+1)+f(x,y1)4f(x,y)
由上式可得其卷积核如下:
[ 0 1 0 1 − 4 1 0 1 0 ] \begin{bmatrix} 0 & 1&0\\ 1 & -4&1 \\0 &1&0\\ \end{bmatrix} 010141010
更多变体:
(1) [ 1 1 1 1 − 8 1 1 1 1 ] \begin{bmatrix} 1 & 1&1\\ 1 & -8&1 \\1 &1&1\\ \end{bmatrix} 111181111 ,(2) [ 0 − 1 0 − 1 4 − 1 0 − 1 0 ] \begin{bmatrix} 0 & -1&0\\ -1 & 4&-1 \\0 &-1&0\\ \end{bmatrix} 010141010 ,(3) [ − 1 − 1 − 1 − 1 8 − 1 − 1 − 1 − 1 ] \begin{bmatrix} -1 & -1&-1\\ -1 & 8&-1 \\-1 &-1&-1\\ \end{bmatrix} 111181111

综上,卷积核(1)增加了±45°方向,(2)&(3)仅为符号的差异,产生的效果相同,但是需要注意当拉普拉斯滤波过后的图像与原图进行加减操作时的符号差异

OpenCV函数:


void cv::Laplacian(InputArray src, OutputArray dst, int ddepth, int ksize = 1, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT)	Parameters
src				Source image.
dst				Destination image of the same size and the same number of channels as src .
ddepth			Desired depth of the destination image, see combinations.
ksize			Aperture size used to compute the second-derivative filters. See getDerivKernels for details. The size must be positive and odd.
scale			Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See getDerivKernels for details.
delta			Optional delta value that is added to the results prior to storing them in dst .
borderType		Pixel extrapolation method, see BorderTypes. BORDER_WRAP is not supported.

2、 一阶导数锐化

f ( x ) f(x) f(x)的一阶导数定义为差分
∂ f ∂ x = f ( x + 1 ) − f ( x ) \frac{\partial f}{\partial x}=f(x+1)-f(x) xf=f(x+1)f(x)
在图像处理中,一阶导数是用梯度幅度实现的。图像f在(x,y)处的梯度定位为二维列向量
∇ f = g r a d ( f ) = [ g x g y ] = [ ∂ f ∂ x ∂ f ∂ y ] \nabla f=grad(f)=\begin{bmatrix}g_x\\ g_y \end{bmatrix}=\begin{bmatrix} \frac {\partial f}{\partial x} \\ \\\frac {\partial f} {\partial y} \end{bmatrix} f=grad(f)=[gxgy]= xfyf
向量 ∇ f \nabla f f的幅度表示为 M ( x , y ) M(x,y) M(x,y),其中
M ( x , y ) = ∥ f ∥ = m a g ( ∇ f ) = g x 2 + g y 2 M(x,y)=\parallel f \parallel=mag(\nabla f)=\sqrt{g_x^2+g_y^2} M(x,y)=∥f∥=mag(f)=gx2+gy2
在某些实现中,使用绝对值来近似平方运算和平方根的运算,
M ( x , y ) ≈ ∣ g x ∣ + ∣ g y ∣ M(x,y)\approx |g_x|+|g_y| M(x,y)gx+gy
M ( x , y ) M(x,y) M(x,y)图像与原图尺寸大小相同,对应原图所有像素位置上的变化,该图像又叫做梯度图像

离散的一阶导数卷积核有如下:

1、Roberts滤波器
Roberts算子的原理是通过计算对角方向相邻两个像素之差来计算图像的梯度大小和方向。梯度大小表示边缘的强度,梯度方向与边缘的走向垂直。
Roberts算法在边缘定位方面较为准确,但对噪声比较敏感,无法有效抑制噪声的影响。因此,它常被用于检测边缘明显、亮度差异较大的低噪声图像。

计算方式:
计算45°方向: g x ( x , y ) = f ( x + 1 , y ) − f ( x , y + 1 ) g_x(x,y)=f(x+1,y)-f(x,y+1) gx(x,y)=f(x+1,y)f(x,y+1),滤波核如下:
M x = [ 0 1 − 1 0 ] M_x=\begin{bmatrix} 0 & 1\\ -1 & 0 \\ \end{bmatrix} Mx=[0110]
计算135°方向, g y ( x , y ) = f ( x , y ) − f ( x + 1 , y + 1 ) g_y(x,y)=f(x,y)-f(x+1,y+1) gy(x,y)=f(x,y)f(x+1,y+1),滤波核如下:
M y = [ 1 0 0 − 1 ] M_y=\begin{bmatrix} 1 & 0\\ 0 & -1 \\ \end{bmatrix} My=[1001]

2、Prewitt滤波器
Prewitt算子利用像素点上下左右邻点的灰度差,在边缘处达到极值来检测边缘,对噪声具有平滑的作用。Prewitt算子同样也是一种基于局部差分计算的算法,由两个 3 ∗ 3 3*3 33的模板组成,一个模板用于计算水平方向的梯度,另一个用于计算垂直方向的梯度。与Roberts算子相比,Prewitt算子的检测效果更加准确,仅稍微增加一些计算量就可以抑制噪音的影响。但是相较于Sobel算子和Laplacian算子,Prewitt算子的边缘检测效果较差。
M x = [ − 1 0 1 − 1 0 1 − 1 0 1 ] M_x=\begin{bmatrix} -1 & 0&1\\ -1 & 0&1 \\-1&0&1\\ \end{bmatrix} Mx= 111000111
M y = [ 1 1 1 0 0 0 − 1 − 1 1 ] M_y=\begin{bmatrix} 1 & 1&1\\ 0 & 0&0 \\-1&-1&1\\ \end{bmatrix} My= 101101101

3、Sobel滤波器
Sobel算子可以在边缘检测时可以提供较为精确的边缘方向信息,对于噪声也具有一定的平滑作用。Sobel算子可以通过像素点上下、左右邻点灰度加权差,在边缘处达到极值这一现象检测边缘,是高斯平滑和微分求导的联合运算,抗噪声能力强。考虑了距离对权值的影响,距离越远的像素的影响越小。可以通过快速卷积实现,简单有效,应用广泛。
M x = [ − 1 0 1 − 2 0 2 − 1 0 1 ] M_x=\begin{bmatrix} -1 & 0&1\\ -2 & 0&2 \\-1&0&1\\ \end{bmatrix} Mx= 121000121
M y = [ 1 2 1 0 0 0 − 1 − 2 1 ] M_y=\begin{bmatrix} 1 & 2&1\\ 0 & 0&0 \\-1 &-2&1\\ \end{bmatrix} My= 101202101

void cv::Sobel(InputArray src, OutputArray dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT)	Parameters
src				input image.
dst				output image of the same size and the same number of channels as src .
ddepth			output image depth, see combinations; in the case of 8-bit input images it will result in truncated derivatives.
dx				order of the derivative x.
dy				order of the derivative y.
ksize			size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
scale			optional scale factor for the computed derivative values; by default, no scaling is applied (see getDerivKernels for details).
delta			optional delta value that is added to the results prior to storing them in dst.
borderType		pixel extrapolation method, see BorderTypes. BORDER_WRAP is not supported.

4、Scharr滤波器
Scharr算子是对Sobel算法的改进和增强。Scharr算子和Sobel算子在边缘检测原理和使用方式上基本相同。Scharr算子使用 3 ∗ 3 3*3 33的滤波器,通过增大像素值间的差异来检测图像的边缘。它在X方向和Y方向上都有对应的边缘检测算子。

相比于Sobel算子,Scharr算子在权重系数上有所调整,使得其在图像梯度的计算中更为敏感。具体来说,Scharr算子使用的权重系数相对Sobel算子更大,以增强梯度的响应。这使得Scharr算子在对边缘进行检测时具有更好的精度和效果。

M x = [ − 3 0 3 − 10 0 10 − 3 0 3 ] M_x=\begin{bmatrix} -3 & 0&3\\ -10 & 0&10 \\-3&0&3\\ \end{bmatrix} Mx= 31030003103
M y = [ 3 10 3 0 0 0 − 3 − 10 3 ] M_y=\begin{bmatrix} 3 & 10&3\\ 0 & 0&0 \\-3 &-10&3\\ \end{bmatrix} My= 30310010303

void cv::Scharr	(InputArray src, OutputArray dst, int ddepth, int dx, int dy, double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT)	Parameters
src				input image.
dst				output image of the same size and the same number of channels as src.
ddepth			output image depth, see combinations
dx				order of the derivative x.
dy				order of the derivative y.
scale			optional scale factor for the computed derivative values; by default, no scaling is applied (see getDerivKernels for details).
delta			optional delta value that is added to the results prior to storing them in dst.
borderType		pixel extrapolation method, see BorderTypes. BORDER_WRAP is not supported.
http://www.yayakq.cn/news/191907/

相关文章:

  • 专门做三国战纪的网站叫什么免费国内linux服务器
  • 有哪个网站可以做兼职餐饮公司 网站建设
  • 怎么让网站能被百度到谷粉搜索谷歌搜索
  • 成都网站建设公司招聘建设各网站需要多久
  • 彩票网站net网站开发找那家湖州市城市建设档案馆网站
  • jsp 交互网站开发技术 西安交通大学出版社 2005.10哈尔滨网站备案
  • 合肥义城建设集团有限公司网站中国企业查询网官网
  • 互联网网站模版江北区网络推广技巧
  • 大理做网站哪家好用电脑做网站
  • 网站定时数据切换怎么做的网络运营商是什么意思
  • 网站问答平台推广方案医疗产品设计公司
  • 网站的二次开发是什么意思wordpress 文章显示数量
  • 烟台网站备案如何用wordpress搭建网站
  • 怎么做网站弄网盟wordpress引流插件
  • 建设网站海报文案做网站素材在哪找
  • 哈尔滨百度网站快速优化网络编程技术试题
  • 古镇小企业网站建设备案查询系统
  • 吕梁网站制作吕梁安全什么网站专门做外围的
  • 网站建立的步骤是( )。设计欣赏网
  • 手机网站焦点图企业平台有哪些
  • wordpress 下载站点连云港 网站设计
  • 克拉玛依市建设局网站嵌入式软件开发工资
  • 微网站开发教程静态网站更新文章麻烦
  • 网站后台树形菜单样式推广哪个平台好
  • 如何部署asp网站网站集群建设要求
  • 社区门户网站规范化建设永州网站建设哪里有
  • 图书馆建设网站免费制作自己的网站长
  • flash网站源代码搬家公司网站模板
  • 织梦网如何把做网站的删掉网站建设工程师职责
  • 国贸做网站公司做教育app的网站有哪些内容