given a 3D direction [x,y,z], a surface normal in this case, how can
we histogram it in a similar way?
In the first case you quantize the polar orientation theta
of the gradients. Now you need to quantize the spherical orientations theta
and phi
in a 2D histogram.
Do we just project onto one plane and use that angle
The binning of the sphere determines how you summarize the information to build a compact yet descriptive histogram.
Projecting the normal is not a good idea, if theta
is more important than phi
, just use more bins for theta
EDIT
Timothy Shields points in his comment and his answer that a regular binning of theta
and phi
won't produce a regular binning over the sphere as the bins will be bunched toward the poles.
His answer gives a solution. Alternatively, the non-regular binning described here can be hacked as follows:
Phi
is quantized regularly in [0,pi]
. For theta
rather than quantizing the range [0,pi]
, the range [-1,1]
is quantized instead;
For each quantized value u
in [-1,1]
, theta
is computed as
theta = arcsin(sqrt(1 - u * u)) * sign(u)
sign(u)
returns -1
if u
is negative, 1
otherwise.
The computed theta
along with phi
produce a regular quantization over the sphere.
To have an idea of the equation given above look at this article. It describes the situation in the context of random sampling though.
EDIT
In the above hack Timothy Shields points out that only the area of the bins is considered. The valence of the vertices (point of intersection of neighboring bins) won't be regular because of the poles singularity.
A hack for the previous hack would be to remesh the bins into a regular quadrilateral mesh and keep the regular area.
A heuristic to optimize this problem with the global constraints of having the same valence and the area can be inspired from Integer-Grid Maps Quad Meshing.
With the two hacks, this answer is too hacky and a little out of context as opposed to Timothy Shields answer.