拉普拉斯——拉普拉斯算子

梯度

梯度描述了多维函数的变化方向,也就是对应该方向函数的变化率(导数来体现)最大,也就是对应方向的方向导数最大,所以其实际是一个有大小有方向的向量。
偏导数描述了某个维度上(对应一个坐标轴上)的函数的变化趋势,这些偏导数构成基本量来描述每个维度的分量,各个维度的分量组合为一个向量也就能描述函数在多维空间的变化趋势。

g

r

a

d

f

(

x

,

y

)

=

(

f

(

x

,

y

)

x

,

f

(

x

,

y

)

y

)

=

f

x

(

x

,

y

)

i

+

f

y

(

x

,

y

)

j

gradf(x,y)=(\frac{\partial f(x,y)}{\partial x},\frac{\partial f(x,y)}{\partial y})=f_x(x,y)i+f_y(x,y)j

gradf(x,y)=(xf(x,y),yf(x,y))=fx(x,y)i+fy(x,y)j (二元,多元同理)
这里的

f

x

(

x

,

y

)

,

f

y

(

x

,

y

)

f_x(x,y),f_y(x,y)

fx(x,y),fy(x,y)为数量大小,

i

i

i

j

j

j是数轴方向(基),一起描述了其向量的大小与方向。
梯度操作的对象是无方向的常量(分布),最终产生的是一个有方向的矢量。

散度

散度是用来描述通量的,而通量是描述单位时间流过(方向与对应面垂直)某个面的量(该量是矢量),由其定义可以得到通量的表示

F

n

d

s

\iint\overrightarrow{F} \cdot \overrightarrow{n}ds

F
n
ds
,其中

F

\overrightarrow{F}

F
为矢量场,对应的

n

\overrightarrow{n}

n
是积分

d

s

ds

ds的法向量,表示的是量的垂直通过,对于封闭面的通量就有这样的形式

F

n

d

s

\oiint\overrightarrow{F} \cdot \overrightarrow{n}ds


F
n
ds
。散度的描述是关于封闭曲面的,用封闭曲面的总通量平均到其围成的体积中

1

V

F

n

d

s

\frac{1}{V}\oiint\overrightarrow{F} \cdot \overrightarrow{n}ds

V1
F
n
ds
,(

V

V

V是对应曲面所围成的体积),得到一个平均的量来描述在这个区域中每个小的区域对通量的贡献,但是这个描述是描述总的趋势(即量是涌入该封闭曲面,还是向外涌出),并不能描述切实的每个点的具体情况,于是对这个区域进行取极限令其趋于无穷小的一点,就可以得到该点处散度的情况

lim

V

>

0

1

V

F

n

d

s

\lim\limits_{V->0}\frac{1}{V}\oiint\overrightarrow{F} \cdot \overrightarrow{n}ds

V>0limV1
F
n
ds

然而这个新式的描述并不能体现其全部的含义,对于向量场

F

\overrightarrow{F}

F
可以变换成多个维度基的形式,假设是一个三维的有

F

=

F

x

i

+

F

y

j

+

F

z

k

\overrightarrow{F}=F_xi+F_yj+F_zk

F
=
Fxi+Fyj+Fzk
,其中的i,j,k为三个坐标轴的方向,于是原先的表示可以变化为

lim

V

>

0

1

V

F

x

d

y

d

z

+

F

y

d

x

d

z

+

F

z

d

x

d

y

\lim\limits_{V->0}\frac{1}{V}\oiint F_xdydz+F_ydxdz+F_zdxdy

V>0limV1
Fxdydz+
Fydxdz+Fzdxdy
,在直角坐标系中

V

V

V趋于无穷小,于是我们可以以

d

x

d

y

d

z

dxdydz

dxdydz来描述对应的体积

V

V

V,于是有散度为

1

d

x

d

y

d

z

(

(

(

F

x

+

d

F

x

)

F

x

)

d

y

d

z

+

(

(

F

y

+

d

F

y

)

F

y

)

d

x

d

z

+

(

(

F

z

+

d

F

z

)

F

z

)

d

x

d

y

)

\frac{1}{dxdydz}(((F_x+dF_x)-F_x)dydz+((F_y+dF_y)-F_y)dxdz+((F_z+dF_z)-F_z)dxdy)

dxdydz1(((Fx+dFx)Fx)dydz+((Fy+dFy)Fy)dxdz+((Fz+dFz)Fz)dxdy)(在各个坐标方向用微分表示)
于是有散度

d

i

v

=

1

d

x

d

y

d

z

(

d

F

x

d

y

d

z

+

d

F

y

d

x

d

z

+

d

F

z

d

x

d

y

)

=

d

F

x

d

x

+

d

F

y

d

y

+

d

F

z

d

z

div=\frac{1}{dxdydz}(dF_xdydz+dF_ydxdz+dF_zdxdy)=\frac{dF_x}{dx}+\frac{dF_y}{dy}+\frac{dF_z}{dz}

div=dxdydz1(dFxdydz+dFydxdz+dFzdxdy)=dxdFx+dydFy+dzdFz,由于是多元的函数,所以应该是偏导

d

i

v

=

F

x

x

+

F

y

y

+

F

z

z

div=\frac{\partial F_x}{\partial x}+\frac{\partial F_y}{\partial y}+\frac{\partial F_z}{\partial z}

div=xFx+yFy+zFz。在这一形式中我们可以看到,散度就是关于各个维度方向上矢量场变化率的标量和,通过统一各个方向上的聚散情况来表现该点处的情况。

形式

现在有一个函数

f

(

x

,

y

)

f(x,y)

f(x,y)(二元函数),对应的梯度为

g

r

a

d

f

(

x

,

y

)

=

(

f

(

x

,

y

)

x

,

f

(

x

,

y

)

y

)

=

f

x

(

x

,

y

)

i

+

f

y

(

x

,

y

)

j

gradf(x,y)=(\frac{\partial f(x,y)}{\partial x},\frac{\partial f(x,y)}{\partial y})=f_x(x,y)i+f_y(x,y)j

gradf(x,y)=(xf(x,y),yf(x,y))=fx(x,y)i+fy(x,y)j,得到梯度这个矢量场之后再进行散度的运算有

d

i

v

(

g

r

a

d

f

(

x

,

y

)

)

=

f

x

x

+

f

y

y

=

2

f

x

2

+

2

f

y

2

div(gradf(x,y))=\frac{\partial f_x}{\partial x}+\frac{\partial f_y}{\partial y}=\frac{\partial^2f}{\partial x^2}+\frac{\partial^2 f}{\partial y^2}

div(gradf(x,y))=xfx+yfy=x22f+y22f,这就是拉普拉斯算子的形式,是梯度的散度。

旋转

对相应的坐标旋转进行推导,原先的极坐标方程为:

{

x

=

r

c

o

x

θ

y

=

r

s

i

n

θ

\left\{\begin{aligned}x=rcox\theta \\y=rsin\theta\end{aligned}\right.

{x=rcoxθy=rsinθ,旋转

β

\beta

β角后,

{

x

=

r

c

o

x

(

θ

+

β

)

y

=

r

s

i

n

(

θ

+

β

)

\left\{\begin{aligned}x\’=rcox(\theta+\beta) \\y\’=rsin(\theta+\beta)\end{aligned}\right.

{x=rcox(θ+β)y=rsin(θ+β)展开一下:

{

x

=

r

c

o

x

θ

c

o

s

β

r

s

i

n

θ

s

i

n

β

y

=

r

s

i

n

θ

c

o

s

β

+

r

c

o

s

θ

s

i

n

β

=

{

x

=

x

c

o

s

β

y

s

i

n

β

y

=

y

c

o

s

β

+

x

s

i

n

β

\left\{\begin{aligned}x\’=rcox\theta cos\beta-rsin\theta sin\beta \\y\’=rsin\theta cos\beta+rcos\theta sin\beta\end{aligned}\right.=\left\{\begin{aligned}x\’=xcos\beta-ysin\beta \\y\’=y cos\beta+x sin\beta\end{aligned}\right.

{x=rcoxθcosβrsinθsinβy=rsinθcosβ+rcosθsinβ={x=xcosβysinβy=ycosβ+xsinβ
代换一下为

{

x

=

x

c

o

s

β

+

y

s

i

n

β

y

=

y

c

o

s

β

x

s

i

n

β

\left\{\begin{aligned}x=x\’cos\beta+y\’sin\beta \\y=y \’cos\beta-x\’sin\beta\end{aligned}\right.

{x=xcosβ+ysinβy=ycosβxsinβ
相应的偏导为:

{

f

x

=

f

x

x

x

+

f

y

y

x

f

y

=

f

x

x

y

+

f

y

y

y

=

{

f

x

=

f

x

c

o

s

β

f

y

s

i

n

β

f

y

=

f

x

s

i

n

β

+

f

y

c

o

s

β

\left\{\begin{aligned}\frac{\partial f}{\partial x\’}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial x\’}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial x\’} \\\frac{\partial f}{\partial y\’}=\frac{\partial f}{\partial x}\frac{\partial x}{\partial y\’}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial y\’} \end{aligned}\right.=\left\{\begin{aligned}\frac{\partial f}{\partial x\’}=\frac{\partial f}{\partial x}cos\beta-\frac{\partial f}{\partial y}sin\beta\\\frac{\partial f}{\partial y\’}=\frac{\partial f}{\partial x}sin\beta+\frac{\partial f}{\partial y}cos\beta \end{aligned}\right.

xf=xfxx+yfxyyf=xfyx+yfyy=xf=xfcosβyfsinβyf=xfsinβ+yfcosβ

不变

拉普拉斯算子具有旋转不变性,在旋转了

β

\beta

β角之后有:

{

x

=

x

c

o

s

β

+

y

s

i

n

β

y

=

y

c

o

s

β

x

s

i

n

β

\left\{\begin{aligned}x=x\’cos\beta+y\’sin\beta \\y=y \’cos\beta-x\’sin\beta\end{aligned}\right.

{x=xcosβ+ysinβy=ycosβxsinβ

{

x

=

x

c

o

s

β

y

s

i

n

β

y

=

y

c

o

s

β

+

x

s

i

n

β

\left\{\begin{aligned}x\’=xcos\beta-ysin\beta \\y\’=y cos\beta+x sin\beta\end{aligned}\right.

{x=xcosβysinβy=ycosβ+xsinβ

即:

2

f

(

x

,

y

)

x

2

+

2

f

(

x

,

y

)

y

2

=

2

f

(

x

,

y

)

x

2

+

2

f

(

x

,

y

)

y

2

\frac{\partial^2f(x,y)}{\partial x^2}+\frac{\partial^2 f(x,y)}{\partial y^2}=\frac{\partial^2f(x\’,y\’)}{\partial x\’^2}+\frac{\partial^2f(x\’,y\’)}{\partial y\’^2}

x22f(x,y)+y22f(x,y)=x22f(x,y)+y22f(x,y)

展开一下:

f

(

x

,

y

)

x

x

+

f

(

x

,

y

)

y

y

\frac{\partial\frac{\partial f(x\’,y\’)}{\partial x\’}}{\partial x\’}+\frac{\partial\frac{\partial f(x\’,y\’)}{\partial y\’}}{\partial y\’}

xxf(x,y)+yyf(x,y)

=

x

(

f

x

c

o

s

β

f

y

s

i

n

β

)

+

y

(

f

x

s

i

n

β

+

f

y

c

o

s

β

)

=\frac{\partial}{\partial x\’}(\frac{\partial f}{\partial x}cos\beta-\frac{\partial f}{\partial y}sin\beta)+\frac{\partial}{\partial y\’}(\frac{\partial f}{\partial x}sin\beta+\frac{\partial f}{\partial y}cos\beta)

=x(xfcosβyfsinβ)+y(xfsinβ+yfcosβ)

=

x

(

f

x

c

o

s

β

f

y

s

i

n

β

)

x

x

+

y

(

f

x

c

o

s

β

f

y

s

i

n

β

)

y

x

+

x

(

f

x

s

i

n

β

+

f

y

c

o

s

β

)

x

y

+

y

(

f

x

s

i

n

β

+

f

y

c

o

s

β

)

y

y

=\frac{\partial}{\partial x}(\frac{\partial f}{\partial x}cos\beta-\frac{\partial f}{\partial y}sin\beta)\frac{\partial x}{\partial x\’}+\frac{\partial}{\partial y}(\frac{\partial f}{\partial x}cos\beta-\frac{\partial f}{\partial y}sin\beta)\frac{\partial y}{\partial x\’}+\frac{\partial}{\partial x}(\frac{\partial f}{\partial x}sin\beta+\frac{\partial f}{\partial y}cos\beta)\frac{\partial x}{\partial y\’}+\frac{\partial}{\partial y}(\frac{\partial f}{\partial x}sin\beta+\frac{\partial f}{\partial y}cos\beta)\frac{\partial y}{\partial y\’}

=x(xfcosβyfsinβ)xx+y(xfcosβyfsinβ)xy+x(xfsinβ+yfcosβ)yx+y(xfsinβ+yfcosβ)yy

{

x

x

=

c

o

s

β

y

x

=

s

i

n

β

x

y

=

s

i

n

β

y

y

=

c

o

s

β

\left\{\begin{aligned}\frac{\partial x}{\partial x\’}=cos\beta \\\frac{\partial y}{\partial x\’}=-sin\beta\\\frac{\partial x}{\partial y\’}=sin\beta \\\frac{\partial y}{\partial y\’}=cos\beta\end{aligned}\right.

xx=cosβxy=sinβyx=sinβyy=cosβ

=

(

2

f

x

2

c

o

s

β

2

f

x

y

s

i

n

β

)

c

o

s

β

(

2

f

x

y

c

o

s

β

2

f

y

2

s

i

n

β

)

s

i

n

β

+

(

2

f

x

2

s

i

n

β

+

2

f

x

y

c

o

s

β

)

s

i

n

β

+

(

2

f

x

y

s

i

n

β

+

2

f

y

2

c

o

s

β

)

c

o

s

β

=(\frac{\partial^2 f}{\partial x^2}cos\beta-\frac{\partial^2 f}{\partial x\partial y}sin\beta)cos\beta-(\frac{\partial^2 f}{\partial x\partial y}cos\beta-\frac{\partial^2 f}{\partial y^2}sin\beta)sin\beta+(\frac{\partial^2 f}{\partial x^2}sin\beta+\frac{\partial^2 f}{\partial x\partial y}cos\beta)sin\beta+(\frac{\partial^2 f}{\partial x\partial y}sin\beta+\frac{\partial^2 f}{\partial y^2}cos\beta)cos\beta

=(x22fcosβxy2fsinβ)cosβ(xy2fcosβy22fsinβ)sinβ+(x22fsinβ+xy2fcosβ)sinβ+(xy2fsinβ+y22fcosβ)cosβ

=

(

2

f

x

2

c

o

s

2

β

+

2

f

x

2

s

i

n

2

β

)

+

(

2

f

y

2

c

o

s

2

β

+

2

f

y

2

s

i

n

2

β

)

=(\frac{\partial^2 f}{\partial x^2}cos^2\beta+\frac{\partial^2 f}{\partial x^2}sin^2\beta)+(\frac{\partial^2 f}{\partial y^2}cos^2\beta+\frac{\partial^2 f}{\partial y^2}sin^2\beta)

=(x22fcos2β+x22fsin2β)+(y22fcos2β+y22fsin2β)

=

2

f

(

x

,

y

)

x

2

+

2

f

(

x

,

y

)

y

2

=\frac{\partial^2f(x,y)}{\partial x^2}+\frac{\partial^2 f(x,y)}{\partial y^2}

=x22f(x,y)+y22f(x,y)

离散

在具体的图像像素处理中,拉普拉斯算子的应用是离散的。首先定义一个二元的函数

f

(

x

,

y

)

f(x,y)

f(x,y),在图像中分别代表着长与宽的方向,对应的一阶偏导数为

f

(

x

+

1

,

y

)

f

(

x

,

y

)

x

+

1

x

\frac{f(x+1,y)-f(x,y)}{x+1-x}

x+1xf(x+1,y)f(x,y)

f

(

x

,

y

+

1

)

f

(

x

,

y

)

y

+

1

y

\frac{f(x,y+1)-f(x,y)}{y+1-y}

y+1yf(x,y+1)f(x,y),同理的二阶导数为

f

(

x

+

1

,

y

)

f

(

x

,

y

)

x

+

1

x

f

(

x

,

y

)

f

(

x

1

,

y

)

x

(

x

1

)

x

+

1

x

\frac{\frac{f(x+1,y)-f(x,y)}{x+1-x}-\frac{f(x,y)-f(x-1,y)}{x-(x-1)}}{x+1-x}

x+1xx+1xf(x+1,y)f(x,y)x(x1)f(x,y)f(x1,y),

f

(

x

,

y

+

1

)

f

(

x

,

y

)

y

+

1

y

f

(

x

,

y

)

f

(

x

,

y

1

)

y

(

y

1

)

y

+

1

y

\frac{\frac{f(x,y+1)-f(x,y)}{y+1-y}-\frac{f(x,y)-f(x,y-1)}{y-(y-1)}}{y+1-y}

y+1yy+1yf(x,y+1)f(x,y)y(y1)f(x,y)f(x,y1),化简一下有:
一阶导数为:

f

(

x

+

1

,

y

)

f

(

x

,

y

)

f(x+1,y)-f(x,y)

f(x+1,y)f(x,y)

f

(

x

,

y

+

1

)

f

(

x

,

y

)

f(x,y+1)-f(x,y)

f(x,y+1)f(x,y)
二阶导数为:

f

(

x

+

1

,

y

)

+

f

(

x

1

,

y

)

2

f

(

x

,

y

)

f(x+1,y)+f(x-1,y)-2f(x,y)

f(x+1,y)+f(x1,y)2f(x,y)

f

(

x

,

y

+

1

)

+

f

(

x

,

y

1

)

2

f

(

x

,

y

)

f(x,y+1)+f(x,y-1)-2f(x,y)

f(x,y+1)+f(x,y1)2f(x,y)
拉普拉斯算子为:

f

(

x

+

1

,

y

)

+

f

(

x

1

,

y

)

+

f

(

x

,

y

+

1

)

+

f

(

x

,

y

1

)

4

f

(

x

,

y

)

f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)-4f(x,y)

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

]

\left[ \begin{matrix}0 & 1 & 0 \\1 & -4 & 1 \\0 & 1 & 0\end{matrix} \right]

010141010,如果加上斜的四个方向就是

[

1

1

1

1

8

1

1

1

1

]

\left[ \begin{matrix}1 & 1 & 1 \\1 & -8 & 1 \\1 & 1 & 1\end{matrix} \right]

111181111
对应长与宽的方向反转也可以是:

[

0

1

0

1

4

1

0

1

0

]

\left[ \begin{matrix}0 & -1 & 0 \\-1 & 4 & -1 \\0 & -1 & 0\end{matrix} \right]

010141010

[

1

1

1

1

8

1

1

1

1

]

\left[ \begin{matrix}-1 & -1 & -1 \\-1 & 8 & -1 \\-1 & -1 & -1\end{matrix} \right]

111181111

很直观的可以看到拥有相同颜色的区域像素值的大小相似,处理之后区域的颜色相同,不同颜色之间的区域处理之后就会显示出色彩的跃升变化,由于数值的大小不同会出现灰度[0,255]之外的值,对应只要将其置为0(小于0)与255(大于255),于是就”黑白分明”了。一般图像边缘的色度会有很大变化,所以常用于边缘识别。从梯度与散度来看,梯度获得了其色彩变化的趋势(一个矢量场),散度则处理了色彩变化的聚散特征。

版权声明:本文为yanzs原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/yanzs/p/13788228.html