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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file napari-stl-exporter-0.0.10.tar.gz.

File metadata

  • Download URL: napari-stl-exporter-0.0.10.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for napari-stl-exporter-0.0.10.tar.gz
Algorithm Hash digest
SHA256 18c45e82e0eec94ba03a2570630390c59e5e726bd3aea7fb79235cabc48c0dc7
MD5 f78df50f16f34ffc82d11e48f7879344
BLAKE2b-256 326d6b2744b0a39bdec8f398bf9ab0bea7ec498cf4d6b0d7049bf15a73458780

See more details on using hashes here.

File details

Details for the file napari_stl_exporter-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_stl_exporter-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a72c64838a4fb1be2561fb18325201e9d09c28e249e286e0bbf8fd67656c3de4
MD5 fae8cf7b9f53268be3ff551fe2c425b8
BLAKE2b-256 5a86b9aaf988cd9a3e207b4c61dbef3a4d69d7f8156be79ec83e0ca687a816c8

See more details on using hashes here.

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