基于OpenCL的加速像素和对象分类器
项目描述
加速像素和对象分类器 (APOC)
clesperanto 与 scikit-learn 结合,用于在GPU上使用 OpenCL 对图像中的像素和对象进行分类。此存储库包含python开发人员的后端。用户友好的插件可在以下位置找到
- napari-accelerated-pixel-and-object-classification
- clijx-accelerated-pixel-and-object-classification
有关从图像和标签掩码文件夹对对进行分类器的训练,请参阅 此笔记本。
对象分割
给定一个blob图像和相应的注释...
import apoc
from skimage.io import imread, imshow
import pyclesperanto_prototype as cle
image = imread('blobs.tif')
imshow(image)
manual_annotations = imread('annotations.tif')
imshow(manual_annotations, vmin=0, vmax=3)
... 可以分割对象(查看完整示例)
# define features: original image, a blurred version and an edge image
features = apoc.PredefinedFeatureSet.medium_quick.value
# Training
clf = apoc.ObjectSegmenter(opencl_filename='object_segmenter.cl', positive_class_identifier=2)
clf.train(features, manual_annotations, image)
# Prediction
segmentation_result = clf.predict(image=image)
cle.imshow(segmentation_result, labels=True)
对象分类
给定注释,也可以根据其形状对blob进行分类(查看完整示例)。
features = 'area,mean_max_distance_to_centroid_ratio,standard_deviation_intensity'
# Create an object classifier
classifier = apoc.ObjectClassifier("object_classifier.cl")
# Training
classifier.train(features, segmentation_result, annotation, image)
# Prediction / determine object classification
classification_result = classifier.predict(segmentation_result, image)
cle.imshow(classification_result, labels=True)
对象选择器
如果期望的分析目标是选择特定类别的对象,则可以使用对象选择器(查看完整示例)。
features = 'area,mean_max_distance_to_centroid_ratio,standard_deviation_intensity'
cl_filename = "object_selector.cl"
# Create an object classifier
apoc.erase_classifier(cl_filename) # delete it if it was existing before
classifier = apoc.ObjectSelector(cl_filename, positive_class_identifier=1)
# train it
classifier.train(features, labels, annotation, image)
result = classifier.predict(labels, image)
cle.imshow(result, labels=True)
对象合并器
APOC还提供了一个 ObjectMerger
,允许在标签边缘上训练分类器以决定合并它们或保留它们。(查看完整示例)
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)
更多详细示例
安装
您可以使用conda或pip安装apoc
conda install -c conda-forge apoc-backend
或者
conda install pyopencl
pip install apoc
Mac用户请也安装此软件
conda install -c conda-forge ocl_icd_wrapper_apple
Linux用户请也安装此软件
conda install -c conda-forge ocl-icd-system
贡献
欢迎贡献。可以使用pytest
运行测试,请在提交拉取请求前确保覆盖率至少保持不变。
许可
根据BSD-3许可证发布,"apoc"是免费且开源的软件
问题
如果您遇到任何问题,请在image.sc上创建一个主题,并附上详细描述和标签@haesleinhuepf。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
apoc-0.12.0.tar.gz (21.3 kB 查看哈希值)
构建分发
apoc-0.12.0-py3-none-any.whl (25.6 kB 查看哈希值)
关闭
apoc-0.12.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c6e5264f2ac0420e5f8e2b23ad16927126d75280bb12f0341480ef9853973263 |
|
MD5 | eac0016ff2997e80aab6a0dc7fb5d325 |
|
BLAKE2b-256 | 12bb169a16a810cac65b6c5f0f69cc4d1e4df17269194efb072721e6e899fbf1 |
关闭
apoc-0.12.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0603edad68ab5fdd46e5e2ddada5749f4fb55e475e0a49ce0aab9b599dae2c2d |
|
MD5 | b1a82b9c9a99670f4c1191e8dfc349c5 |
|
BLAKE2b-256 | df714aedecc8c3d92e6496248b5b01a45fb28705ea305284fd3875073f4344bd |