How to get the laplacian of a scalar field?

Click For Summary

Discussion Overview

The discussion revolves around calculating the Laplacian of a scalar field, particularly in the context of applying reaction diffusion to 2D images and extending this concept to 3D volumes. Participants explore the appropriate weights for summing neighboring values and the potential discrepancies between manual calculations and built-in tools.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes their approach to calculating the Laplacian in 2D and expresses uncertainty about whether their method is indeed the Laplacian.
  • Another participant suggests that the weights for summing neighbors in 3D should relate to the number of surrounding cells, noting that 3D has 26 neighbors compared to 8 in 2D.
  • A participant confirms that the weights are tied to the number of surrounding cells and explains that the weights must cancel out, with the original cell having a negative weight.
  • One participant references a Wikipedia page on the discrete Laplace operator as a potential resource for the calculations needed.
  • A later reply indicates that adjusting the calculation by dividing the result by 6 resolved some issues encountered in the 3D implementation.

Areas of Agreement / Disagreement

Participants generally agree on the relationship between the number of neighbors in 2D and 3D and the need for weights to cancel out. However, there remains uncertainty regarding the specific weights to use in 3D and the discrepancies between manual calculations and built-in tools.

Contextual Notes

Participants mention potential issues with values going to infinity after several iterations, indicating a need for balance in the calculations. There are also references to differing results from manual calculations versus built-in tools, suggesting unresolved mathematical steps.

cvex
Messages
8
Reaction score
0
Hi,

I am trying to calculate the laplacian of a scalar field but I might actually need something else. So basically I am applying reaction diffusion on a 2d image. I am reading the neighbours, multiplying them with these weights and then add them.

4K0V1JA.png


This works great. I don't know if what I am doing is called laplacian but I was told that it is.

Now I am trying to do the same thing in 3d volumes:
http://www.openvdb.org/

But the problem is I don't know what weights to use to sum the neighbours. If I use the same weights on a 2d volume, it works just the same. But in 3d, I am not sure what the weights would be.

I also tried using actual laplacian (OpenVDB has tools to calculate it), but after 7-8 iterations the values in the volume go to infinity. Maybe what I need is not really laplacian. But whatever is coming from the neighbours has to be in balance so just like in the 2d image version, the values don't get bigger and bigger while nothing is getting smaller. That's my understanding.

I tried calculating the laplacian manually also by using the actual definition, and got different result that the build-in tools. Not sure if I am missing something:
http://paste.ofcode.org/QYUec5tu63AM6n2Bmax6C7

Do you guys know what I need?Cheers :)
 
Last edited by a moderator:
Physics news on Phys.org
Are the weights tied to the number of surrounding cells? So that for 3d you'd have 26 neighbors instead of 8 for 2d.

Or tied the number of lines through the point? so for 2d it would be 4 and for 3d it would be 4+9 or 13.

This is just my guess. It would be best if you knew how the weights are calculated.
 
Last edited:
  • Like
Likes   Reactions: cvex
Thanks a lot for replying. It's tied to the number of surrounding cells. So for 2d, it's 8 and for 3d it's 26 just like you said.

Also the positive and negative weights have to cancel out, which is why in 2d the original cell has a weight of -1 and the surrounding cells have a total weight of 1.

So in a way the 3d volume is like a stack of 2d images.
 
  • Like
Likes   Reactions: cvex
Thanks wolfman, I think that works. I tried it before I think but didn't divide the result by 6 :( Now it seems to work at least.

Thanks a lot :)
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
5
Views
4K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K