def test_watershed_seeded(self): seeds_bool = self.landscape==0 seeds_unique = label(seeds_bool)[0] seeded_watershed_result = numpy.array([1,1,1,1,1,0,2,2,2,0,3,3]) seeded_watershed1 = morpho.watershed(self.landscape, seeds_bool) seeded_watershed2 = morpho.watershed(self.landscape, seeds_unique) self.assertTrue((seeded_watershed1 == seeded_watershed_result).all()) self.assertTrue((seeded_watershed2 == seeded_watershed_result).all())
def test_watershed_saddle_basin(self): saddle_landscape = numpy.array([[0,0,3],[2,1,2],[0,0,3]]) saddle_result = numpy.array([[1,1,1],[0,0,0],[2,2,2]]) saddle_ws = morpho.watershed(saddle_landscape) self.assertTrue((saddle_ws==saddle_result).all())
def test_watershed_seeded_nodams(self): seeds_bool = self.landscape==0 seeded_nodam_ws_result = numpy.array([1,1,1,1,1,1,2,2,2,3,3,3]) seeded_nodam_ws = \ morpho.watershed(self.landscape, seeds=seeds_bool, dams=False) self.assertTrue((seeded_nodam_ws == seeded_nodam_ws_result).all())
def test_watershed_nodams(self): nodam_watershed_result = numpy.array([1,1,1,2,2,2,3,3,3,4,4,4]) nodam_watershed = morpho.watershed(self.landscape, dams=False) self.assertTrue((nodam_watershed == nodam_watershed_result).all())
def test_watershed(self): regular_watershed_result = numpy.array([1,1,1,0,2,0,3,3,3,0,4,4]) regular_watershed = morpho.watershed(self.landscape) self.assertTrue((regular_watershed == regular_watershed_result).all())
def test_watershed_images(self): wss = [morpho.watershed(self.probs[i]) for i in range(3)] + \ [morpho.watershed(self.probs[3], dams=False)] for i in range(self.num_tests): self.assertTrue((wss[i]==self.results[i]).all(), 'Watershed test number %i failed.'%(i+1))