How to voxelize a .STL file

Tags: #<Tag:0x00007fb8820681b8>


I’m wanting to break down a . STL file to a stack of voxel images so that I can use ImageJ functions for 3d image analysis. Is there a plugin available?

LimeSeg - a particle active contour method for 3D segmentation

[Edit]: the suggestion below does not work as stated for loaded STL files as indicated by @iarganda

Hi @kcstauffer,

it should be possible with the 3D Viewer. You can load .STL files into the 3D Viewer via the ►File menu. Then you can still apply transformations to the object and export it to a stack via ►Edit ►Transformation ►Export transformed image. The result will the 3D stack.


Hello @biovoxxel, I don’t think you can do that unless there is an underlying grayscale image. I just tried it out and got an error:



Hi @iarganda,

Autsch :confounded:
Sorry for the incorrect indication. You are right. I obviously had the input stack open ando forgot that the STL file actually only comprises the surface and does not have the intensity info available.
So just forget about my earlier suggestion.


Hi all,

We added voxelization to imagej-ops a bit ago:



I don’t know much about coding. Do you have a compressed .jar file so that I can just drop it into the plugins folder and have it work?


Almost! Or rather: there is almost a working ImageJ update site.

We added a page about voxelization to the ImageJ wiki awhile ago. However, those instructions are now outdated. The “ThreeDViewer” is now known as SciView. Much time and effort is being expended by @kephale and @skalarproduktraum and myself to get it to a usable state. One of its features is voxelization of meshes.

We are in the middle of a hackathon this week madly working on this stuff. So please stay tuned; hopefully we will have something for you to try soon.


Looking forward to it. Thanks!


Do we have any update from the December Hackathon? Is the a stable combination of plugins that can Voxelize an .stl today?



Not stable. But experimental, yes: you can enable the SciView update site to give it a try as described here (that documentation still says “ThreeDViewer” but the instructions are probably OK otherwise? @kephale?)

Note that the SciView update site is intentionally not on the built-in list of update sites yet, because it is not yet stable enough. But you can use the “Add update site” button to add it manually.

There will be another hackathon in late April specifically dedicated to SciView—the development continues!


Hey all,

Actually, to help tease apart graphics and mesh processing dependencies I added a STL voxelization script to FunImageJ.

Just enable the FunImageJ update site (it is in the standard update site list), then access the command via the menu at: Plugins>FunImageJ>Mesh>voxelize mesh. It asks for a STL file and voxel dimensions as input.

Note that voxelization is not a trivial problem, and if you get an unexpected result, then please contact me and I will look into it. There are a couple of folks who are joining me to dive a bit further into some fancier voxelization algorithms in the near future (coinciding with the SciView hackathon).



Dear Kyle,

I tried to load a simple stl of 12MB, no luck. tried other files, the same error, which I’m posting below. Any help welcome:

[ERROR] null
java.util.NoSuchElementException, compiling:(NO_SOURCE_FILE:0:0)
	at clojure.lang.Compiler$InvokeExpr.eval(
	at clojure.lang.Compiler$InvokeExpr.eval(
	at clojure.lang.Compiler$DefExpr.eval(
	at clojure.lang.Compiler.eval(
	at clojure.lang.Compiler.eval(
	at org.scijava.plugins.scripting.clojure.ClojureScriptEngine.eval(
	at org.scijava.plugins.scripting.clojure.ClojureScriptEngine.eval(
	at org.scijava.thread.DefaultThreadService$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.util.NoSuchElementException
	at java.util.LinkedHashMap$LinkedHashIterator.nextNode(
	at java.util.LinkedHashMap$
	at net.imagej.ops.geom.geom3d.DefaultVoxelization3D.calculate(
	at net.imagej.ops.geom.geom3d.DefaultVoxelization3D.calculate(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at clojure.lang.Reflector.invokeMatchingMethod(
	at clojure.lang.Reflector.invokeInstanceMethod(
	at fun.imagej.ops$run_op.invokeStatic(ops.clj:129)
	at fun.imagej.ops$run_op.invoke(ops.clj:125)
	at clojure.lang.AFn.applyToHelper(
	at clojure.lang.AFn.applyTo(
	at clojure.lang.Compiler$InvokeExpr.eval(
	... 15 more
[ERROR] null


Can you post one of the stl’s as an example? I just tried and it still seems to work for me.