How to use the gala.optimized.flood_fill function in gala

To help you get started, we’ve selected a few gala examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github janelia-flyem / gala / tests / test_optimized.py View on Github external
def test_flood_fill_basic():
    fail_message = 'Flood fill failed to find all matching labels.'
    t1 = opt.flood_fill(_flood_fill_example(), (0,0,0), [0], None, True)
    assert_equal(set(t1), set([0,4,5,9,12,13]), fail_message)
    t2 = opt.flood_fill(_flood_fill_example(), (0,0,3), [5], None, True)
    assert_equal(set(t2), set([3,14,15,19,23]), fail_message)
github janelia-flyem / gala / tests / test_optimized.py View on Github external
def test_flood_fill_multiple_acceptable():
    fail_message = 'Flood fill failed to flood with multiple acceptable labels'
    t1 = opt.flood_fill(_flood_fill_example(), (1,1,1), [1,4], None, True)
    assert_equal(set(t1), set([8,10,16,17,18,20,22]), fail_message)
    t2 = opt.flood_fill(_flood_fill_example(), (0,1,2), [2,5], None, True)
    assert_equal(set(t2), set([2,3,6,11,14,15,19,23]), fail_message)
github janelia-flyem / gala / tests / test_optimized.py View on Github external
def test_flood_fill_pipes():
    fail_message = 'Flood fill failed with thin columns in large volume.'
    example3 = np.random.randint(6, size=(200,200,200))
    example3[2,2,:] = 6
    example3[:,2,150] = 6
    example3[45,:,:] = 6
    t8 = opt.flood_fill(example3, (2,2,0), [6], None, True)
    assert_equal(len(t8), (example3==6).sum(), fail_message)
github janelia-flyem / gala / tests / test_optimized.py View on Github external
def test_flood_fill_multiple_acceptable():
    fail_message = 'Flood fill failed to flood with multiple acceptable labels'
    t1 = opt.flood_fill(_flood_fill_example(), (1,1,1), [1,4], None, True)
    assert_equal(set(t1), set([8,10,16,17,18,20,22]), fail_message)
    t2 = opt.flood_fill(_flood_fill_example(), (0,1,2), [2,5], None, True)
    assert_equal(set(t2), set([2,3,6,11,14,15,19,23]), fail_message)
github janelia-flyem / gala / gala / agglo.py View on Github external
def extent(self, nodeid):
        try:
            ext = self.extents
            full_ext = [ext[f] for f in self.node[nodeid]['fragments']]
            return np.concatenate(full_ext).astype(np.intp)
        except AttributeError:
            extent_array = opt.flood_fill(self.watershed,
                               np.array(self.node[nodeid]['entrypoint']),
                               np.fromiter(self.node[nodeid]['fragments'],
                                           dtype=int))
            if len(extent_array) != self.node[nodeid]['size']:
                sys.stderr.write('Flood fill fail - found %d voxels but size'
                                 'expected %d\n' % (len(extent_array),
                                                    self.node[nodeid]['size']))
            raveled_indices = np.ravel_multi_index(extent_array.T,
                                                   self.watershed.shape)
            return set(raveled_indices)