Skip to content

clEsperanto/pyclesperanto

pyclesperanto

Image.sc Forum Conda Version PyPI License Development Status Build codecov DOI

pyclesperanto is the python package of clEsperanto - a multi-language framework for GPU-accelerated image processing. It relies on a familly of OpenCL kernels originated from CLIJ. This python package uses PyBind11 to wrap the C++ CLIc library as a processing backend.

Installation, Documentation, and Uses

To install pyclesperanto from pip:

pip install pyclesperanto

Please, refere to the documentation for full installation instructions and options, guides, and examples on how to use the pyclesperanto. If you encountering any difficulties or have questions we encourage you to raise them on the image.sc forum under the tag clesperanto, or to open a github issue.

Code Example

import pyclesperanto as cle
from skimage.io import imread, imsave

# initialize GPU
device = cle.select_device()
print("Used GPU: ", device)

image = imread("https://samples.fiji.sc/blobs.png?raw=true")

# push image to device memory
input_image = cle.push(image)

# process the image
inverted = cle.subtract_image_from_scalar(input_image, scalar=255)
blurred = cle.gaussian_blur(inverted, sigma_x=1, sigma_y=1)
binary = cle.threshold_otsu(blurred)
labeled = cle.connected_components_labeling(binary)

# The maxmium intensity in a label image corresponds to the number of objects
num_labels = cle.maximum_of_all_pixels(labeled)

# print out result
print("Num objects in the image: " + str(num_labels))

# read image from device memory
output_image = cle.pull(labeled)
imsave("result.tif", output_image)

Examples & Demos

More usage and example can be found as notebooks in the tutorial section of the documentation as well as in the docs/demos folder of the repository.

Contributing and Feedback

clEsperanto is developed in the open because we believe in the open source community. Feel free to drop feedback as github issue or via image.sc. Contributions, of any kind, are very welcome. Feel free to reach out to us. And if you liked our work, star the repository, share it with your friends, and use it to make cool stuff!

Acknowledgements

We acknowledge support by the Deutsche Forschungsgemeinschaft under Germany’s Excellence Strategy (EXC2068) Cluster of Excellence Physics of Life of TU Dresden and by the Institut Pasteur, Paris. This project has been made possible in part by grant number 2021-237734 (GPU-accelerating Fiji and friends using distributed CLIJ, NEUBIAS-style, EOSS4) from the Chan Zuckerberg Initiative DAF, an advised fund of the Silicon Valley Community Foundation, and by support from the French National Research Agency via the France BioImaging research infrastructure (ANR-24-INBS-0005 FBI BIOGEN).

Contributors

Languages