seung-lab / zmesh

Marching Cubes & Mesh Simplification on multi-label 3D images.
GNU General Public License v3.0
59 stars 8 forks source link

Endianness affects meshing #41

Open davidackerman opened 5 months ago

davidackerman commented 5 months ago

Hello,

I have noticed that the endianness of the labels array affects the ids that the mesher reports. For example

import zmesh
import numpy as np

for endian in ['<','>']:
    labels = np.zeros((11, 17, 19), dtype=np.dtype(f'{endian}i8'))
    labels[1:-1, 1:-1, 1:-1] = 1

    mesher = zmesh.Mesher((4, 4, 40))
    mesher.mesh(labels)

    print(f"{endian} endian, ids: {mesher.ids()}")

results in:

< endian, ids: [1]
> endian, ids: [72057594037927936]

I can fix the problem by swapping the byteorder, but figured I'd point it out. I had noticed a similar fix in the skeletonization code.