mkazhdan / PoissonRecon

Poisson Surface Reconstruction
MIT License
1.59k stars 430 forks source link

PoissonRecon with Dirichlet 'creates multiple hulls' #283

Closed Sheradil closed 1 year ago

Sheradil commented 1 year ago

Hello, I have a problem with the poisson reconstruction. It's not a bug, just weird behaviour.

At first I tried using the PCL. Then Open3D. Both didn't achieve good results. Then a former colleague pointed me towards this page. When the point clouds get reconstructed ~50% are reconstructed as I would expect. The other half is really messy.

My objects are similar to a cuboid, but one side is missing (like a trash bin). And I want the Poisson Reconstruction to close around the object and fill the 'missing' side. First attempts resulted in a shape with a large round open hole that bulge outside (like a vase). That does make sense (I used the wrong boundary condition, therefore no watertight result). Then I sampled points within the space where the cuboid is open (generated normals and aligned them with open3d) and I used the Dirichlet boundary condition, hoping that the poisson reconstruction would close the mesh.

The normal vectors that open3d generates look ok'ish. They are not perfect, but ok. In this specific case the normals of the original cloud point inwards and those that I sampled point outward. But in many other cases they are both aligned (so both the cloud points and the sampled points point outwards or inwards). So the normals are not the only reason why it fails.

And what happens now, does not really make sense to me. Instead of simply closing 'around' the hole, the mesh bulges backward all around the object generating a 2 layered mesh as if you stack 2 mugs. And the sampled points are treated like a flap/tap.

I hope the attached images help to understand what I mean. In this image you can see the original (dense) cloud, the sampled points and the vertices of the reconstructed mesh. In the bottom left I tried to give a side view of what is happening. The dotted lines are the original cloud and the drawn line is the mesh afterwards. Cloud and Reconstructed cloud The same clouds from a top down view. From the top down view you can see a hole. Reconstructed cloud from top The reconstructed mesh. Reconstructed Mesh

I am confused why the result looks like this and why the poisson reconstruction does not simply close the mesh using the sampled points. I can share a few point clouds if that helps. The parameters that I used for reconstruction are the default parameters + "bType 2" to use the dirichlet boundary condition. I tried changing some parameters, but didn't have success. Can you direct me in the correct direction (I also tried the SSD Recon)?

mkazhdan commented 1 year ago

I am not 100% sure that I am following, but if you are using Dirichlet conditions on the surface of the bounding cube, then the sign of the normals make a difference and the assumption is that they should be pointing outwards. (No such assumption holds for the default Neumann boundary conditions.)

One way to think about this is is in terms of the reconstructed indicator function: The indicator function has large value inside the volume and small/zero value outside. In terms of gradients, this is achieved by having the implicit function increase as it goes across the surface boundary, with the direction of increase in the opposite direction of the normals. In the case that your normals are pointing inward you have two competing objectives:

  1. The implicit function should be large on the side of the points closer to the sides of the bounding cube (because of the normal orientation).
  2. The implicit function should be small/zero at the sides of the bounding cube (because of the Dirichlet conditions). The implementation resolves this by introducing an additional layer of surface between the smalls and the sides of the bounding box, allowing the indicator function to transition from the large value you prescribed on the outer side of the points to the zero value forced by the Dirichlet conditions.
Sheradil commented 1 year ago

When I used the von Neumann condition I read about the normals and that normals in a neighborhood should point in the same direction. When I switched to Dirichlet so that I always get a watertight result, I assumed that the same criteria applies to the normals here. I didn't know that they should point outwards.

But with your explanation the results make sense. The 2nd layer that is generated is plausible now. I quickly fixed the orientation of the normals and now they point outside (for the most part that is). Now the reconstructions are much better and don't show 2-layered surfaces any more. There are point clouds where the reconstruction does not work, but they are difficult to reconstruct anyway due to their shape. Knowing that the orientation of the normals is of such high importance, I am certain that the normal estimation causes the remaining issues.

Thanks a lot for your help and your explanation of the implicit function and it's role! Appreciate your help