1

谁能解释为什么我在 Matlab 中使用 Laplace 算子时得到如此显着不同的结果

laplacian = del2(image);

相对

[x, y] = gradient(image);
[xx, xy] = gradient(x);
[yx, yy] = gradient(y);
laplacian = xx + yy;

这些不应该是同一件事吗?当一个包含 dx 项时,它们会变得特别不同。

把我的例子放在这里以防万一:我有一个测试字段,包括

 [5; 2.5+2.5i; 5i; -2.5+2.5i; -5; -2.5-2.5i; -5i; 2.5-2.5i] 

乘以它的转置(如果有帮助,我可以发布整个矩阵)。该字段的 del2() 的内部块 (3:6, 3:6) 是:

[-2.5           -0.625-0.625i  -2.5i           0.625-0.625i ;
 -0.625+0.625i   0             -0.625+0.625i   0            ;
  2.5i          -0.625+0.625i  -2.5           -0.625+0.625i ;
  0.625+0.625i   0             -0.625+0.625i   0            ] 

而 xx + yy 的内部块 (3:6, 3:6) 是:

[-5             -2.5-2.5i      -5i            -2.5-2.5i     ; 
 -2.5+2.5i      -2.5           -2.5-2.5i      -2.5i         ; 
  5i            -2.5+2.5i      -5             -2.5-2.5i     ; 
  2.5+2.5i       2.5i          -2.5+2.5i      -2.5          ]

如您所见,这将对任何进一步的方程式产生巨大的影响。哪位大神能解释一下,万分感谢!

4

2 回答 2

2

正如您在del2 的文档中看到的那样,它与您比较1/4梯度方法不同。

This partly explains that factor 4 in your example. I blame the rest on edge effects :p

于 2012-09-10T16:03:47.990 回答
1

If you look closely at Matlab's documentation, the laplacian of f at (x,y), del2(f(x,y)) is computed using only (x,y) and its nearest neighbours: x+1, x-1, y+1, y-1.

The same goes for the gradient function (and the divergence, which explicitly uses the gradient function). Computing the gradient twice involves the nearest neighbours of the nearest neighbours. Therefore div(grad(f(x,y)) is actually computed using (x,y) and x+2, x-2, y+2, y-2. Hence the difference.

The greater the grid spacing, the greater the discrepancy between these two calculations will be.

于 2017-04-25T14:44:01.490 回答