Pregunta

I am trying to quantize surface normals into let's say 8 bins.

For example, when computing features like HOG to quantize 2D gradients [x,y] into 8 bins we just take the angle with the y plane i.e. arctan(y/x) which will give us an angle between 0-360.

My question is, given a 3D direction [x,y,z], a surface normal in this case, how can we histogram it in a similar way? Do we just project onto one plane and use that angle i.e. the dot product of [x,y,z] and [0,1,0] for example?

Thanks

EDIT

I also read a paper recently where they quantized surface normals by measuring angles between normal and precomputed vectors that which are arranged around a right circular cone shape. I have added a link to this paper in the question (section 3.3.2 last paragraph), is this an effective approach? And if so, how do we compute these vectors?

¿Fue útil?

Solución

Quantizing a continuous topological space corresponds to partitioning it and assigning labels to each partition. The straightforward standard approach for this scenario (quantizing normals) is as follows.

  1. Choose your favorite uniform polyhedron:
  2. Develop a mapping function from a normal on the unit sphere to the face of your chosen polyhedron that the normal intersects.
    • I would advise doing an argmax across polyhedron faces, taking the dot product of your normal and each polyhedron face normal. The one that gives the highest dot product is the face your normal should be binned into.
  3. Use the face normal for each polyhedron face as the label for that face.

Prefer this approach to the approach suggested by others of mapping to spherical coordinates and then binning those. That approach suffers from too much sensitivity near the poles of the sphere.

Edit

In the paper you added to your question, the same idea is being used. There, however, the normals are restricted to a hemisphere - the only surfaces directly visible in an image have surface normals no more than 90 degrees away from the vector from the surface to the viewpoint.

The paper wants to quantize these surface normals into 8 values, represented by 8-bit integers with exactly one bit set to 1 and the rest set to 0. The 8 precomputed normals are computed as:

ntx = cos(a)*cos(t)

nty = cos(a)*sin(t)

ntz = sin(a)

where a = pi/4 and t = 0, pi/4, 2*pi/4, 3*pi/4, ..., 7*pi/4.

Notice

[cos(a)*cos(t)]2 + [cos(a)*sin(t)]2 + [sin(a)]2 = cos2(a)[cos2(t) + sin2(t)] + sin2(a) = cos2(a) + sin2(a) = 1

Otros consejos

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.

A 3-dimensional normal cannot be quantized into a 1-D array as easily as for a 2-D normal (e.g., using arctan). I would recommend histogramming it into a 2-d space with a polar angle and an azimuth angle. For example, use spherical coordinates where the r (radius) value is always 1.0 (since your surface normal is normalized, length 1.0). In this case, you can throw away the r-value and just use polar angle θ (theta), and azimuthal angle φ (phi) to quantize the 3D normal.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top