seung-lab / connected-components-3d

Connected components on discrete and continuous multilabel 3D & 2D images. Handles 26, 18, and 6 connected variants; periodic boundaries (4, 8, & 6)
GNU Lesser General Public License v3.0
356 stars 42 forks source link

Build Equivalence Table Two Z Slices at a Time #98

Open william-silversmith opened 2 years ago

william-silversmith commented 2 years ago

For very large volumes, it might be helpful to be able to provide a facility for processing Z slices in sequential order. This would allow the user to manage memory efficiently on their end. The interface would look something like:

import cc3d
import numpy as np

builder = cc3d.connected_components_builder()
for z in range(128):
     builder.add_z_slice(img[:,:,z])
for z in range(128):
     img[:,:,z] = builder.relabel(img[:,:,z])