I'm having a depth image, say z = f(x, y)
with (x, y)
in pixels. I want to calculate the normal vector at each pixel to create the normal map.
I've been trying the approach at Calculate surface normals from depth image using neighboring pixels cross product. In this approach, basically the "input" to the cross product is two tangent vectors, which are the gradients (dz/dx)
and (dy/dx)
. These two tangent vectors will form the tangent plane at point (x, y, f(x, y))
, and then the cross product will find the normal vector to this plane.
However, I don't understand why the normal vector to this plane (3D plane (x, y, f(x, y))
will also be the normal vector to the plane in world coordinates that I'm trying to find. Is there any assumption here? How can this approach be used to find the normal vector at each pixel?