Package: apoc
Accelerated Pixel and Object Classifiers (APOC)clesperantomeetsscikit-learnto classify pixels and objects in images, on aGPUusingOpenCL.
This repository contains the backend for python developers. User-friendly plugins forFijiandnaparican be found here:napari-accelerated-pixel-and-object-classificationclijx-accelerated-pixel-and-object-classificationFor training classifiers from pairs of image and label-mask folders, please seethis notebook.Object segmentationWith a given blobs image and a corresponding annotation...importapocfromskimage.ioimportimread,imshowimportpyclesperanto_prototypeascleimage=imread('blobs.tif')imshow(image)manual_annotations=imread('annotations.tif')imshow(manual_annotations,vmin=0,vmax=3)... objects can be segmented (see full example):# define features: original image, a blurred version and an edge imagefeatures=apoc.PredefinedFeatureSet.medium_quick.value# Trainingclf=apoc.ObjectSegmenter(opencl_filename='object_segmenter.cl',positive_class_identifier=2)clf.train(features,manual_annotations,image)# Predictionsegmentation_result=clf.predict(image=image)cle.imshow(segmentation_result,labels=True)Object classificationWith 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 classifierclassifier=apoc.ObjectClassifier("object_classifier.cl")# Trainingclassifier.train(features,segmentation_result,annotation,image)# Prediction / determine object classificationclassification_result=classifier.predict(segmentation_result,image)cle.imshow(classification_result,labels=True)Object selectorIf the desired analysis goal is to select objects of a specific class, the object selector can be used (see full example).features='area,mean_max_distance_to_centroid_ratio,standard_deviation_intensity'cl_filename="object_selector.cl"# Create an object classifierapoc.erase_classifier(cl_filename)# delete it if it was existing beforeclassifier=apoc.ObjectSelector(cl_filename,positive_class_identifier=1)# train itclassifier.train(features,labels,annotation,image)result=classifier.predict(labels,image)cle.imshow(result,labels=True)Object mergerAPOC also comes with aObjectMergerallowing to train a classifier on label edges for deciding to merge them or to keep them.
(See full example)feature_definition="touch_portion mean_touch_intensity"classifier_filename="label_merger.cl"apoc.erase_classifier(classifier_filename)classifier=apoc.ObjectMerger(opencl_filename=classifier_filename)classifier.train(features=feature_definition,labels=oversegmented,sparse_annotation=annotation,image=background_subtracted)merged_labels=classifier.predict(labels=oversegmented,image=background_subtracted)cle.imshow(merged_labels,labels=True)More detailed examplesObject segmentationObject classificationObject classification based on custom measurement tablesPixel classifier (including benchmarking).Output probability mapsContinue training of pixel classifiers using multiple training image pairsGenerating custom feature stacksInstallationYou can installapocusing conda or pip:conda install -c conda-forge apoc-backendOR:conda install pyopencl
pip install apocMac-users please also install this:conda install -c conda-forge ocl_icd_wrapper_appleLinux users please also install this:conda install -c conda-forge ocl-icd-systemContributingContributions are very welcome. Tests can be run withpytest, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of the BSD-3 license,
"apoc" is free and open source softwareIssuesIf you encounter any problems, pleaseopen a thread on image.scalong with a detailed description and tag@haesleinhuepf.