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

邢台推广网站建设电话asp.net网站开发教程下载

邢台推广网站建设电话,asp.net网站开发教程下载,企业做网站步骤,哪些公司做网站改造空间滤波基础二:锐化 锐化的作用的突出灰度中的过渡。图像锐化通过空间微分来实现,微分将增强边缘和其他不连续(噪声),不强化灰度变化缓慢的区域。图像锐化也叫做高通滤波,通过高频,抑制低频。…

空间滤波基础二:锐化

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

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/92641/

相关文章:

  • 襄阳高新区建设局网站个人备案网站可以做产品推广
  • 外包公司做网站多少钱做网站跟app需要多少钱
  • 贵阳制作网站的公司合优做网站需要多少钱
  • 什么网站好网站跳转到另外一个网站怎么做
  • 文案写作网站网址域名大全2345网址
  • 哪些网站是做婴童辅食招商的淄博做网站建设
  • 外贸网站建设定做南宁网站seo顾问
  • 三亚市住房和城乡建设局网站房产信息网哪个好
  • 网站设计文稿网站制作时间代码
  • 江苏建设教育网站河南 网站备案
  • 用wampserver搭建网站网站的建设费用
  • 网站网页进口旅游景点网站设计
  • 有哪些做画册的网站网站怎么在移动端推广
  • 如何用rp做网站中山网站建设外包
  • 设计师网站1688北京市建设规划网站
  • 北京高端网站设计外包公司企业网络规划设计与实现
  • 那个外贸网站做的最好do_action wordpress
  • 网站如何连接微信支付宝吗设计公司logo设计图片
  • 网站开发需要多少钱厦门it做网站最强
  • 简述jsp网站架构环保网站 中企动力建设
  • 四川网站建设方案手机网站整站模板下载
  • 广州网站建设及推广外贸企业网站建设一条龙
  • 梅州市建设培训中心网站西安造价信息网官网
  • 沧州网站建设益志科技大连建设学院网站
  • 爱站网怎么用廊坊网站制作报价
  • 湛江网站推广优化网站定位策划
  • 电子商务网站建设与设计论文企业邮箱是qq邮箱吗
  • 网站做分站WordPress模板注释
  • 如需手机网站建设成华区微信网站建
  • 网站流量统计怎么做的哪建设网站好