Error with large models

Dear Michael,

I use BoneJ to create STL files within Fiji in the field of material sciences.

An error occurs during the calculation of the isosurface when the model is to large. The isosurface contains over 40,000,000 triangles and I have set the resampling factor to 1. It seems that the error is inside the 3D viewer after executing the marching cubes algorithm.

Error message:

(Fiji Is Just) ImageJ 2.0.0-rc-43/1.50e; Java 1.6.0_24 [64-bit]; Windows 7 6.1; 17905MB of 61000MB (29%) java.lang.NegativeArraySizeException at javax.media.j3d.GeometryArrayRetained.createGeometryArrayData(GeometryArrayRetained.java:1639) at javax.media.j3d.GeometryArray.<init>(GeometryArray.java:873) at javax.media.j3d.GeometryArray.<init>(GeometryArray.java:611) at javax.media.j3d.GeometryArray.<init>(GeometryArray.java:466) at javax.media.j3d.TriangleArray.<init>(TriangleArray.java:64) at customnode.CustomTriangleMesh.createGeometry(CustomTriangleMesh.java:111) at customnode.CustomMesh.update(CustomMesh.java:76) at customnode.CustomMesh.<init>(CustomMesh.java:59) at customnode.CustomTriangleMesh.<init>(CustomTriangleMesh.java:35) at customnode.CustomTriangleMesh.<init>(CustomTriangleMesh.java:29) at org.doube.bonej.MeasureSurface.renderSurface(MeasureSurface.java:133) at org.doube.bonej.MeasureSurface.run(MeasureSurface.java:113) at ij.IJ.runUserPlugIn(IJ.java:212) at ij.IJ.runPlugIn(IJ.java:176) at ij.Executer.runCommand(Executer.java:136) at ij.Executer.run(Executer.java:65) at java.lang.Thread.run(Thread.java:662)

Many thanks in advance,
Torsten

This is almost always caused by too-large data. It happens when a 32-bit integer value (maximum value 2147483647) overflows and “wraps around” to a negative value.

Perhaps @mdoube knows a solution in this case, but in general, the workaround is to downsample or reduce the data somehow.

See also http://imagej.net/Troubleshooting#NegativeArraySizeException

Hi @tooor,

Try ticking the option ‘Save as binary STL’ and unticking ‘Show surface’ in BoneJ > Isosurface.

This will write your STL straight to disk without displaying it.

Let us know how you get on. We’ve written some pretty humongous STLs with it, for hi-res 3D printing. @ctrueden’s point on downsampling stands for another practical reason: if your STL is gigantic then your next step that will use the STL may suffer as a result, because all those triangles might choke your GPU or 3D printing machine and make it stall or go really slowly. Try using a resampling value of 2 or 3 (or more) and see whether it qualitatively affects your mesh.

Michael

Hi Michael,

your advice helped me to work around the error. Now I can create the STL file out of the huge image stack (2048x2048 x 909 slices).

Another question is, whether it is possible to specify a lower and upper threshold to extract a STL for each material?

Torsten

The current implementation uses a single threshold along which the STL mesh is wrapped. You could consider this a value boundary, like an isobar in a weathermap. Values lower than the threshold are ‘outside’ the mesh and values higher than the threshold are ‘inside’ the mesh.

If you want your mesh to represent a different segmentation approach (e.g. min and max thresholds, textures, statistical/trainable segmentation), first extract a binary mask of the phase you wish to mesh by applying your segmentation, then run Isosurface again, on the binary mask.

1 Like