4

I was working on a method to approximate the normal to a surface of a 3d voxel image.

The method suggested in this article (only algorithm I found via Google) seems to work. The suggested method from the paper is to find the direction the surface varies the most in, choose 2 points on the tangent plane using some procedure, and then take the cross product. Some Pascal code by the article author code, commented in Portuguese, implements this method.

However, using the gradient of f (use each partial derivative as a component of the vector) as the normal seems to work pretty well; I tested this along several circles on a voxellated sphere and I got results that look correct in most spots (there are a few outliers that are off by about 30 degrees). This is very different from the method used in the paper, but it still works. What I don't understand is why the gradient of f = 1/dist calculated along the surface of an object should produce the normal.

Why does this procedure work? Is it just the fact that the sphere test was too much of a special case? Could you suggest a simpler method, or explain any of these methods?

Thomas
  • 6,515
  • 1
  • 31
  • 47
felipeh
  • 141
  • 1
  • 4
  • Just because if the surface is defined by its implicit equation, the gradient [**is** the normal vector](http://en.wikipedia.org/wiki/Surface_normal#Calculating_a_surface_normal) – Dr. belisarius Jul 08 '11 at 19:18

1 Answers1

1

Using the gradient of the volume as a normal for lighting is a standard technique in volume rendering.

If you interpret the value of a voxel as the opacity, the gradient will give you the direction of the greatest change in the opacity, which is similar to a surface normal.

tkerwin
  • 9,559
  • 1
  • 31
  • 47
  • The problem is that I am not taking the gradient of the image (the 1's and 0's) itself, but of the function defined as f=1/dist, where dist is the distance from the point I want the normal to. How are these related? – felipeh Jul 08 '11 at 20:03
  • If you are just using `f = 1/dist` where `dist` is the distance to the point your normals should be identical between points. If you base it on the voxel values, this is similar to taking the gradient of the local region multiplied by a spherical falloff mask. – tkerwin Jul 08 '11 at 20:11