# [Numpy-discussion] Smoothing a Grid

Ian Mallett geometrian@gmail....
Thu Apr 8 23:19:50 CDT 2010

```Hi,

So I have a 4D grid (x,y,z,vec3), where the vec3 represents a position.

What I want to do is to move vec3 elements of the grid based on surrounding
vec3 elements so that the grid's values overall are more orthogonal.

For example, consider the following 3 x 3 x 3 x vec3 grid:

[[[[-1.0,-1.0,-1.0],[ 0.0,-1.0,-1.0],[ 1.0,-1.0,-1.0]],
[[-1.0,-1.0, 0.0],[ 0.0,-1.0, 0.0],[ 1.0,-1.0, 0.0]],
[[-1.0,-1.0, 1.0],[ 0.0,-1.0, 1.0],[ 1.0,-1.0, 1.0]]],
[[[-1.0, 0.0,-1.0],[ 0.0, 0.0,-1.0],[ 1.0, 0.0,-1.0]],
[[-1.0, 0.0, 0.0],[ 0.2, 0.0, 0.0],[ 1.0, 0.0, 0.0]],
[[-1.0, 0.0, 1.0],[ 0.0, 0.0, 1.0],[ 1.0, 0.0, 1.0]]],
[[[-1.0, 1.0,-1.0],[ 0.0, 1.0,-1.0],[ 1.0, 1.0,-1.0]],
[[-1.0, 1.0, 0.0],[ 0.0, 1.0, 0.0],[ 1.0, 1.0, 0.0]],
[[-1.0, 1.0, 1.0],[ 0.0, 1.0, 1.0],[ 1.0, 1.0, 1.0]]]]

Notice that, with the exception of the middle value, [0.2,0.0,0.0], the vec3
elements in the grid define a 3 x 3 x 3 grid.  The middle value should thus
be moved perhaps 10% of the distance to the target location [0.0,0.0,0.0],
which can be inferred from the surrounding vec3 elements.  After this
movement, the value is [0.18,0.00,0.00].

To be more precise, the target position of each vec3 is determined from the
surrounding values.  Every vec3 moves towards being a certain x_distance
from adjacent vec3s in the x direction.  Every vec3 moves towards being a
certain y_distance from adjacent vec3s in the y direction.  Every vec3 moves
towards being a certain z_distance from adjacent vec3s in the z direction.
Each vec3 also moves towards a certain diagonal_distance from all vec3s
along a major diagonal.

I am trying to accomplish this.  Any ideas?

Thanks,
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100408/6f0a94e1/attachment.html
```