Package: pyclesperanto
py-clesperantopyclesperanto is the python package ofclEsperanto- a multi-language framework for GPU-accelerated image processing.
It relies on a familly ofOpenCL kernelsoriginated fromCLIJ.
This package is developped in python and C++ wrapped usingPyBind11, and uses the C++CLIclibrary as a processing backend.Reference and examplesAn API reference and package documentation can be foundhere, and several demonstration notebook on how to use the library and major functionnality are available in thedemos folderInstallationGet a conda/python environment, e.g. viamamba-forge.If you never used python/conda environments before, please followthese instructionsfirst.Create a new environment and activate it:mamba create --name cle
mamba activate cleInstall pyclesperanto usingmamba / conda:mamba install pyclesperantoMacOSusers may need to install the following package:mamba install ocl_icd_wrapper_appleLinuxusers may need to install the following package:mamba install ocl-icd-systemTroubleshooting: Graphics cards driversIn case you encounter one of the following error messages:"ImportError: DLL load failed while importing cl: The specified procedure could not be found"see also"clGetPlatformIDs failed: PLATFORM_NOT_FOUND_KHR""No backend available. Please install either OpenCL or CUDA on your system.""No device available. Please install either OpenCL or CUDA on your system."please install recent drivers for your graphics card and/or OpenCL device. Select the right driver source depending on your hardware from this list:AMD driversNVidia driversIntel GPU driversMicrosoft Windows OpenCL supportLinux user may have to install packages such asintel-opencl-icdorrocm-opencl-runtimedepending on their GPU.Code ExampleNote: This project is under heavy development. General API, functions, and parameters are subject to change.importpyclesperantoasclefromskimage.ioimportimread,imsave# initialize GPUdevice=cle.select_device()print("Used GPU: ",device)image=imread("https://samples.fiji.sc/blobs.png")# push image to device memoryinput_image=cle.push(image)# process the imageinverted=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_box(binary)# The maxmium intensity in a label image corresponds to the number of objectsnum_labels=cle.maximum_of_all_pixels(labeled)# print out resultprint("Num objects in the image: "+str(num_labels))# read image from device memoryoutput_image=cle.pull(labeled)imsave("result.tif",output_image)Examples & Demos gallerySegment + analyze blobsCell segmentation + Voronoi labeling3D image filteringFind local maxima3D Tribolium nuclei segmentationExplore application programming interface (API)More usage and example can be found as notebooks in thedemosfolderContributing and FeedbackclEsperanto is developed in the open because we believe in the [open source community].
Feel free to drop feedback asgithub issueor viaimage.sc forum.
Contribution are also very welcome. Please read ourcommunity guidelinesbefore you start and get in touch with us so that we can help you get started.
If you liked our work, star the repository, share it with your friends, and use it to make cool stuff!AcknowledgementsWe acknowledge support by the Deutsche Forschungsgemeinschaft under Germany’s Excellence Strategy (EXC2068) Cluster of Excellence Physics of Life of TU Dresden.
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.