本文整理汇总了Python中libdvid.DVIDNodeService.get_sparselabelmask方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.get_sparselabelmask方法的具体用法?Python DVIDNodeService.get_sparselabelmask怎么用?Python DVIDNodeService.get_sparselabelmask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libdvid.DVIDNodeService
的用法示例。
在下文中一共展示了DVIDNodeService.get_sparselabelmask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sparselabelmask
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import get_sparselabelmask [as 别名]
def test_sparselabelmask(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_sparselabelmask")
node_service.create_labelarray("test_sparselabelmask", 64)
# Diagonal Stripes
data = numpy.indices((128,128,128), dtype=numpy.uint16).sum(axis=0).astype(numpy.uint64)
data[:] //= 5
data_downsampled = data[::2,::2,::2].copy('C') # cheap downsampling...
TEST_LABEL = data[64,64,64] # This is a big diagonal that passes through all but the first block.
assert TEST_LABEL in data
assert data.flags['C_CONTIGUOUS']
# Load two scales
node_service.put_labelblocks3D( "test_sparselabelmask", data, (0,0,0) )
node_service.put_labelblocks3D( "test_sparselabelmask", data_downsampled, (0,0,0), scale=1 )
# Retrieve a body at full scale
block_starts, block_masks = node_service.get_sparselabelmask(TEST_LABEL, "test_sparselabelmask", 0)
assert len(block_starts) == len(block_masks) == 7
assert block_masks[0].dtype == numpy.bool
block_stops = block_starts + 64
for start, stop, mask in zip( block_starts, block_stops, block_masks ):
expected_mask = (data[bb_to_slicing(start, stop)] == TEST_LABEL)
assert (mask == expected_mask).all()
# Retrieve that body at half scale
block_starts, block_masks = node_service.get_sparselabelmask(TEST_LABEL, "test_sparselabelmask", 1)
assert len(block_starts) == len(block_masks) == 1
expected_mask = (data_downsampled == TEST_LABEL)
assert (block_starts[0] == (0,0,0)).all()
assert (block_masks[0] == expected_mask).all()