OpenCL based GPU-accelerated image processing (an early prototype)
Project description
pyclesperanto
pyclesperanto is a prototype for clEsperanto - a multi-platform multi-language framework for GPU-accelerated image processing. It uses OpenCL kernels from CLIJ
Right now, this is very preliminary.
Reference
The full reference is available as part of the CLIJ2 documentation.
Installation
- Get a python environment, e.g. via mini-conda
- Install pyopencl.
If installation of pyopencl for Windows fails, consider downloading a precompiled wheel (e.g. from here ) and installing it manually:
pip install pyopencl-2019.1.1+cl12-cp37-cp37m-win_amd64.whl
Afterwards, install pyclesperanto:
pip install pyclesperanto-prototype
Troubleshooting installation
If you receive an error like
DLL load failed: The specified procedure could not be found.
Try downloading and installing a pyopencl with a lower cl version, e.g. cl12 : pyopencl-2020.1+cl12-cp37-cp37m-win_amd64
Example code
A basic image procressing workflow loads blobs.gif and counts the number of gold particles:
import pyclesperanto_prototype as cle
from skimage.io import imread, imsave
# initialize GPU
cle.select_device("GTX")
print("Used GPU: " + cle.get_device().name)
# load data
image = imread('https://imagej.nih.gov/ij/images/blobs.gif')
print("Loaded image size: " + str(image.shape))
# push image to GPU memory
input = cle.push(image)
print("Image size in GPU: " + str(input.shape))
# process the image
inverted = cle.subtract_image_from_scalar(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 objects
num_labels = cle.maximum_of_all_pixels(labeled)
# print out result
print("Num objects in the image: " + str(num_labels))
# for debugging: print out image
print(labeled)
# for debugging: save image to disc
imsave("result.tif", cle.pull(labeled))
Example notebooks and scripts are available for
- Select GPU
- Counting blobs
- Crop and paste images
- Inspecting 3D image data
- Multiply vectors and matrices
- Matrix multiplication
- Working with spots, pointlist and matrices
- Voronoi diagrams
- Tribolium morphometry
- Napari+Dask Timelapse processing
- Napari Particle Analyser
Feedback welcome!
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
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 pyclesperanto_prototype-0.4.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4fe7f931f22b0018ba2811cf664f3f2965c134c12a252ed29f8d95354113e6a |
|
MD5 | 097c048747dc84de1061fb28995957be |
|
BLAKE2b-256 | 0283b8761e80ef40f3104cfda08bd7346f341bdca4a07fc4776ae850fd200f49 |
Hashes for pyclesperanto_prototype-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e05ef9537349f3bd520358f3154d06de8f99ae842ab29c1de7144ba941d4c402 |
|
MD5 | a02968adfc140cf9b39b2e7803984c21 |
|
BLAKE2b-256 | 84eda6df49911fcc4de7b501aba7075306e1c22a3162b4268a64f67d2ad8bd47 |