加快图像标记

问题描述

我有一堆 1000 张图像,其中包含超过 12 万个对象。在第三方软件中运行连接组件算法后,我得到了一张彩色图像,其中每个连接的对象都有一个标签、一个颜色和一个 ID 值。

我需要提取构成每个对象的体素坐标列表。

我已经编写了一个 Python 代码来提取这些信息,但它非常慢,因为它每分钟处理大约 30 个标签。因此,在最佳情况下,处理整个扫描需要 2 天以上的时间。

将堆栈转换为 3D Numpy 数组(img_stack_numpy)后,这里是代码的主要部分:

# Store the labels and its associated voxels in a dictionary
labels,counts = np.unique(img_stack_np,return_counts=True)
labels_list = list(labels)
dict_labels_and_voxels = {}

for label in labels_list:
    
    if label==0:  # We don't want to store the label 0 (background)
        continue
    
    index = np.where(img_stack_np == label)
    dict_labels_and_voxels[label] = [index]
    

我怎样才能提高它的速度?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)