Exports label images to 3D-printable stl files.
Project description
napari-stl-exporter
This plugin allows to convert 3D label images to 3D-printable .stl files using the marching cubes algorithm implemented in scikit-image. The generated stl-files can then be read by common 3D-printing slicer programs (see below).
Usage
The napari-stl-exporter requires labeled, 3D input data. The data is then converted to the 3D-printable .stl format simply by specifying the stl-file extension uppon image export in napari. For simple example data, see here.
Preparing label data
- Programmatically: A Napari Label layer can be added to the viewer as described in the napari reference with this code snippet:
import napari
from skimage import io
# Load and binarize image
data = io.imread('Path to input data')
data[data != 0] = 1
# Add data to viewer
viewer = napari.Viewer()
label_layer = viewer.add_labels(data, name='3D object')
- Interactively: Alternatively, it is possibly to drag and drop example data into the viewer and convert it to a labels layer by rightclicking on the entry in the layer list and select
Convert to Labels
:
Saving data
To save the model as an .stl file, export it by selecting File->Save Selected Layer(s)
and save it as MyModel.stl
, which will automatically call the conversion. Alternativaley, use
napari.save_layers(r'SomePath\test.stl', [label_layer])
to save the previously generated label layer as .stl file. The label layer is then saved as a 3D-printable .stl file if the filename is provided accordingly (e.g., test.stl
).
3D-printing
To actually send your object to a 3D-printer, it has to be further converted to the .gcode format with a Slicer program. The latter convert the 3D object to machine-relevant parameters (printing detail, motor trajectories, etc). Popular slicers are:
- Slic3r: Documentation here
- Prusa Slicer: Tutorial here
You can also upload the STL file to github.com and interact with it in the browser:
This napari plugin was generated with Cookiecutter using with @napari's cookiecutter-napari-plugin template.
Installation
You can install napari-stl-exporter
via pip:
pip install napari-stl-exporter
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the BSD-3 license, "napari-stl-exporter" is free and open source software
Issues
If you encounter any problems, please [file an issue] along with a detailed description or post to image.sc and tag El_Pollo_Diablo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file napari-stl-exporter-0.0.4.tar.gz
.
File metadata
- Download URL: napari-stl-exporter-0.0.4.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d039474783d7e17252aace461f037f2f026225893343014070854994c09e3607 |
|
MD5 | 5e29fe8617a4257e64cc7e97fb3c54fb |
|
BLAKE2b-256 | 4a4ad2e5b94586d93c9fb631f32ef69c96bd7b54134fdcc6d5badb5db6f135fc |