Skip to main content

Exports label images to 3D-printable stl files.

Project description

napari-stl-exporter

License PyPI Python Version tests codecov

This plugin allows to convert data in Napari to 3D-printable [.stl, .ply] files using various algorithms. The generated files can then be read by common 3D-printing slicer programs (see below).

Usage

This section explains which data can be written with the napari-stl-exported and how you can do so.

Supported Napari layers:

Currently supported Napari layer types are:

  • Label layers: The label data is converted to surface data using the marching cubes algorithm implemented in scikit-image and is then exported using Vedo.
  • Surface layers: Surface data can be natively exported with the Vedo library.

Supported file formats:

Currently supported file formats for export include:

  • .stl: Common data format for 3D printing, can be read by common 3D slicer programs (see below)
  • .ply: Common data storage format for surfaces, needs to be converted to .stl either with this plugin or with suitable software (e.g., Blender).

Preparing data

  • Interactively: You can create sample label/surface data for export using the built-in functions as shown here:

To export the data, simply save the selected layer with File > Save Selected Layer(s) and specify the file ending to be some_file.stl or some_file.ply.

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])

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

napari-stl-exporter-0.0.10.tar.gz (8.5 kB view hashes)

Uploaded Source

Built Distribution

napari_stl_exporter-0.0.10-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page