Exports label images to 3D-printable stl files.
Project description
napari-stl-exporter
This plugin allows to import and export surface data in Napari to common file formats. The generated file formats can be read by other common applications, and - in particular - allow 3D-printing.
Usage
This section explains which data can be written with the napari-stl-exported and how you can do so.
Supported file formats:
Currently supported file formats for export include and rely on the vedo io API.
- .stl: Standard triangle language
- .ply: Polygon file format
- .obj: Wavefront object
Supported Napari layers:
Currently supported Napari layer types are:
- Surface layers
- Label layers: The label data is converted to surface data under the hood using the marching cubes algorithm implemented in scikit-image and is then exported using Vedo. Warning: This can be slow for large image data!
Import/export
Interactively: To export the data, simply save the selected layer with File > Save Selected Layer(s)
and specify the file ending to be some_file.[file_ending]
, for supported file types, see above. Similarly, supported file types can be imported into Napari with File >
From code: A Napari Label layer can be added to the viewer as described in the napari reference with this code snippet:
import napari
import numpy as np
# Load and binarize image
label_image = np.zeros((100, 100, 100), dtype=int)
label_image[25:75, 25:75, 25:75] = 1
# Add data to viewer
viewer = napari.Viewer()
label_layer = viewer.add_labels(data, name='3D object')
# save the layer as 3D printable file to disc
napari.save_layers(r'/some/path/test.stl', [label_layer])
Sample data
You can create sample label/surface data for export using the built-in functions as shown here:
...or from code with
import napari_stl_exporter
pyramid = napari_stl_exporter.make_pyramid_surface()
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
Note: 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
Built Distribution
Hashes for napari-stl-exporter-0.0.11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | be9fba0ebb45a2b89e71ab178884719c9e085267a2cf2b10bdc2282e30c70b9b |
|
MD5 | 999d6e0fcafbcd4d2c8ebe8d8b59eb07 |
|
BLAKE2b-256 | 07c7aa7ae41718bc662661ab95bb3f38f6195cbedbdb67c261351b085da4d75f |
Hashes for napari_stl_exporter-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8111e44cd86020f7b0d81edd31563c00c3e3bafdc8e1c3b3b2dd7a8f5c14499 |
|
MD5 | 0d0fe695a9cd2979edfa6d5eaa05c687 |
|
BLAKE2b-256 | ffd92837937369edc0d8de96706ec0c93a0d2fe843a2ad8408b81eeafa5d2e0e |