Skip to main content

Accelerated Pixel and Object Classifiers based on OpenCL

Project description

Accelerated Pixel and Object Classifiers (APOC)

clEsperanto meets sklearn

Object segmentation

With a given blobs image and a corresponding annotation...

from skimage.io import imread, imshow
import pyclesperanto_prototype as cle
import numpy as np
import apoc

image = imread('blobs.tif')
imshow(image)

img.png

manual_annotations = imread('annotations.tif')
imshow(manual_annotations, vmin=0, vmax=3)

img.png

... objects can be segmented (see full example):

# define features: original image, a blurred version and an edge image
features = features = apoc.PredefinedFeatureSet.medium_quick.value

clf = apoc.ObjectSegmenter(opencl_filename='object_segmenter.cl', positive_class_identifier=2)
clf.train(features, manual_annotations, image)

segmentation_result = clf.predict(image=image)
cle.imshow(segmentation_result, labels=True)

img.png

Object classification

With a given annotation, blobs can also be classified according to their shape (see full example).

features = 'area,mean_max_distance_to_centroid_ratio,standard_deviation_intensity'

# Create an object classifier
classifier = apoc.ObjectClassifier("object_classifier.cl")

# train it
classifier.train(features, segmentation_result, annotation, image)

# determine object classification
classification_result = classifier.predict(segmentation_result, image)

imshow(classification_result)

img.png

More detailed examples

Installation

You can install apoc via [pip]. Note: you also need pyopencl.

conda install pyopencl
pip install apoc

Contributing

Contributions are very welcome. Tests can be run with pytest, 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, "apoc" is free and open source software

Issues

If you encounter any problems, please open a thread on image.sc along with a detailed description and tag @haesleinhuepf.

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

apoc-0.5.0.tar.gz (11.2 kB view hashes)

Uploaded Source

Built Distribution

apoc-0.5.0-py3-none-any.whl (12.3 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