Hi Janto,

I just pushed up a PR which can correct this in post - check it out and let us know if things look better in MeshLab!

https://github.com/scikit-image/scikit-image/pull/882

Regards,
Josh


On Wednesday, January 15, 2014 2:38:49 PM UTC-6, Josh Warner wrote:
I think you're right, this could be done in post. And I believe "gradient" in this case should work even for binary input.

I'm keen to work on this, but have some deadlines which will keep me busy until at least next week.

Regards,
Josh

On Monday, January 13, 2014 1:10:46 AM UTC-6, Janto Dreijer wrote:
Thanks Josh,

Unfortunately I need a single sided mesh. The resulting STL will be passed to constructive solid geometry code which needs to know which side is inside/outside.

Could your suggestion of looking at the volume field's gradient be done after running marching_cubes? It might be simpler than extending the internals of marching_cube.
Then again, I'm working with a binary input volume. So I don't really have a gradient...

Regards
Janto

On Friday, January 10, 2014 2:51:56 AM UTC+2, Josh Warner wrote:
Calculate the gradient for each face, normalize it, and orient the face counterclockwise around the descent of said gradient vector.

It would require some pretty heavy modification, but might be worth it.

On the other hand, you could potentially hack in a fix (depends on how the STL package works) much easier by making the output double sided. A double-sided mesh has each face twice, covering both orientations This way you'd just append `faces` to itself, reverse indexing to flip the orientation of each face, e.g.

``` python
import numpy as np
from skimage.measure import marching_cubes

verts, faces = marching_cubes(vol, value)

faces = np.concatenate((faces, faces[:, -1], axis=0)

# Remainder of STL export code for faces here
```

Which would be *far, far* simpler and less computationally intense than dealing with the gradients...

Would you mind trying this quick fix, Janto?


On Wednesday, January 8, 2014 6:35:28 PM UTC-6, Stefan van der Walt wrote:
Josh, you said you had some ideas on how to add this--could you expand?