pmneila/PyMCubes

marching cube smooth

charlieguo0610 opened this issue · 2 comments

Hi,
Thank you for your great work! I have one question regarding the mcube smooth operation: is there a degree to which I can control the call on mcubes.smooth(), such as setting a parameter for smoothness?

Hi,

Yes, you can control the amount of smoothing.

There are two smoothing methods available in mcubes.smooth: gaussian and constrained. By default, the function chooses the method based on the size of the input array, as defined here, but you can force a specific method using the method parameter.

  1. For the gaussian method, you can control the amount of smoothing by passing the argument sigma (default value is 3). You can increase the smoothness by increasing the value of sigma. For example:
mcubes.smooth(array, method='gaussian', sigma=5)

Keep in mind that a high value of sigma can lead to loss of fine details in your surface.

  1. For the constrained method, you can reduce the amount of smoothing by either decreasing the number of iterations max_iters (default 500) or increasing the tolerance rel_tol (default 1e-6). For example:
mcubes.smooth(array, method='constrained', max_iters=50, rel_tol=1e-4)

The constrained method is designed to converge to an optimal solution, meaning it will preserve the details of the surface even with high values of max_iters, which is desirable in some cases. However, in many other cases this is not a requirement and it might seem that the constrained method doesn't provide enough smoothing. In that case, just use the gaussian method.

Hope that clarifies your question.

Yes, I appreciate your explanation!