This piece of code is a port of SurfaceNets originally implemented by Sarah F. Frisken provided along with the paper "SurfaceNets for Multi-Label Segmentations with ...