看了好多帖子,都没有详细简明的推导过程,所以在这里写一下(前提了解导数的极限定义和图像的结构):
-
拉普拉斯算子定义:
\bigtriangledown^2 f = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} -
f(x,y)对x右侧的一阶偏导(因为相邻点像素距离差为1,所以分母为1略去):
\frac{\partial f}{\partial x} = f(x+1,y) - f(x,y) -
f(x,y)对x左侧的一阶偏导(同上):
\frac{\partial f}{\partial x} = f(x,y) - f(x-1,y) -
f(x,y)对x的二阶偏导(右侧一阶减左侧一阶,分母仍然是1略去):
\begin{aligned} \frac{\partial^2 f}{\partial x^2} &= f(x+1,y) - f(x,y) - (f(x,y) - f(x-1,y)) \\ &= f(x+1,y) + f(x-1,y) - 2f(x,y) \end{aligned} -
f(x,y)对y的二阶偏导(同上):
\begin{aligned} \frac{\partial^2 f}{\partial y^2} &= f(x,y+1) - f(x,y) - (f(x,y) - f(x,y-1)) \\ &= f(x,y+1) + f(x,y-1) - 2f(x,y) \end{aligned} -
上面两式相加得到结果:
\begin{aligned} \bigtriangledown^2 f &= f(x+1,y) + f(x-1,y) - 2f(x,y) + f(x,y+1) + f(x,y-1) - 2f(x,y) \\ &= (f(x+1,y) + f(x-1,y) + f(x,y+1) + f(x,y-1)) - 4f(x,y) \end{aligned}
然后按照结果中每个点的权值变成卷积核:
0 | 1 (f(x,y-1)的权值) | 0 |
1 (f(x-1,y)的权值) | -4 (f(x,y)的权值) | 1 (f(x+1,y)的权值) |
0 | 1 (f(x,y+1)的权值) | 0 |
网友评论