本文整理汇总了Python中libdvid.DVIDNodeService.create_labelarray方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.create_labelarray方法的具体用法?Python DVIDNodeService.create_labelarray怎么用?Python DVIDNodeService.create_labelarray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libdvid.DVIDNodeService
的用法示例。
在下文中一共展示了DVIDNodeService.create_labelarray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_labelarray_put_single_block
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelarray [as 别名]
def test_labelarray_put_single_block(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_labelarray_put_single_block")
node_service.create_labelarray("test_labelarray64", 64)
data = numpy.random.randint(0, 10, (64,64,64)).astype(numpy.uint64)
node_service.put_labelblocks3D( "test_labelarray64", data, (0,0,64) )
retrieved_data = node_service.get_labels3D( "test_labelarray64", (64,64,64), (0,0,64) )
assert (retrieved_data == data[:64,:64,:64]).all()
示例2: test_labelarray_put_volumes
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelarray [as 别名]
def test_labelarray_put_volumes(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_labelarray_put_volumes")
node_service.create_labelarray("test_labelarray64_put", 64)
data = numpy.random.randint(0, 10, (128,128,128)).astype(numpy.uint64)
assert data.flags['C_CONTIGUOUS']
node_service.put_labelblocks3D( "test_labelarray64_put", data, (0,0,0) )
retrieved_data = node_service.get_labels3D( "test_labelarray64_put", (30,31,32), (20,20,20) )
assert (retrieved_data == data[20:50, 20:51, 20:52]).all()
retrieved_data = node_service.get_labels3D( "test_labelarray64_put", (64,64,64), (0,0,0) )
assert (retrieved_data == data[:64,:64,:64]).all()
retrieved_data = node_service.get_labels3D( "test_labelarray64_put", (128,128,128), (0,0,0) )
assert (retrieved_data == data).all()
示例3: test_labelarray_get_volumes
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelarray [as 别名]
def test_labelarray_get_volumes(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid, "[email protected]", "test_labelarray_get_volumes")
node_service.create_labelarray("test_labelarray64_get", 64)
data = numpy.random.randint(0, 10, (128,128,128)).astype(numpy.uint64)
assert data.flags['C_CONTIGUOUS']
# Try reading from empty data (before anything is loaded in the instance)
# Should be all zeros
retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (64,128,128), (0,0,0) )
assert (retrieved_data == 0).all()
# Now populate the instance with some data
node_service.put_labelblocks3D( "test_labelarray64_get", data, (0,0,0) )
retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (30,31,32), (20,20,20) )
assert (retrieved_data == data[20:50, 20:51, 20:52]).all()
# First with the ordinary GET
retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (64,64,64), (0,0,0) )
assert (retrieved_data == data[:64,:64,:64]).all()
retrieved_data = node_service.get_labels3D( "test_labelarray64_get", (128,128,128), (0,0,0) )
assert (retrieved_data == data).all()
# Again with the blockwise GET
retrieved_data = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (64,64,64), (0,0,0) )
assert (retrieved_data == data[:64,:64,:64]).all()
retrieved_data = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (128,128,128), (0,0,0) )
assert (retrieved_data == data).all()
# Try the requests-based alternative (request raw via requests.get, then inflate afterwards)
r = requests.get(f'http://{TEST_DVID_SERVER}/api/node/{self.uuid}/test_labelarray64_get/blocks/128_128_128/0_0_0?compression=blocks')
r.raise_for_status()
inflated_data = DVIDNodeService.inflate_labelarray_blocks3D_from_raw(r.content, (128, 128, 128), (0,0,0))
assert (inflated_data == data).all()
# What happens if we request a block that doesn't exist on the server?
missing = node_service.get_labelarray_blocks3D( "test_labelarray64_get", (128,128,128), (1024, 1024, 1024), scale=6 )
assert missing.shape == (128,128,128)
assert (missing == 0).all()
示例4: test_sparselabelmask
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import create_labelarray [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()