本文整理汇总了Python中libdvid.DVIDNodeService.put_gray3D方法的典型用法代码示例。如果您正苦于以下问题:Python DVIDNodeService.put_gray3D方法的具体用法?Python DVIDNodeService.put_gray3D怎么用?Python DVIDNodeService.put_gray3D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libdvid.DVIDNodeService
的用法示例。
在下文中一共展示了DVIDNodeService.put_gray3D方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import put_gray3D [as 别名]
def setUpClass(cls):
"""
Override. Called by nosetests.
"""
# Choose names
cls.dvid_repo = "datasetA"
cls.data_name = "random_data"
cls.volume_location = "/repos/{dvid_repo}/volumes/{data_name}".format( **cls.__dict__ )
cls.data_uuid = get_testrepo_root_uuid()
cls.node_location = "/repos/{dvid_repo}/nodes/{data_uuid}".format( **cls.__dict__ )
# Generate some test data
#data = numpy.random.randint(0, 255, (128, 256, 512, 1)).astype( numpy.uint8 )
data = numpy.zeros((128, 256, 512, 1), dtype=numpy.uint8)
data.flat[:] = numpy.arange( numpy.prod((128, 256, 512, 1)) )
cls.original_data = data
cls.voxels_metadata = VoxelsMetadata.create_default_metadata(data.shape, data.dtype, "zyxc", 1.0, "")
# Write it to a new data instance
node_service = DVIDNodeService(TEST_DVID_SERVER, cls.data_uuid)
node_service.create_grayscale8(cls.data_name)
node_service.put_gray3D( cls.data_name, data[...,0], (0,0,0) )
示例2: test_grayscale_3d
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import put_gray3D [as 别名]
def test_grayscale_3d(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_grayscale8("test_grayscale_3d")
data = numpy.random.randint(0, 255, (128,128,128)).astype(numpy.uint8)
node_service.put_gray3D( "test_grayscale_3d", data, (0,0,0) )
retrieved_data = node_service.get_gray3D( "test_grayscale_3d", (30,30,30), (20,20,20) )
self.assertTrue( (retrieved_data == data[20:50, 20:50, 20:50]).all() )
示例3: test_grayscale_3d
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import put_gray3D [as 别名]
def test_grayscale_3d(self):
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_grayscale8("test_grayscale_3d")
data = numpy.random.randint(0, 255, (128,128,128)).astype(numpy.uint8).transpose()
assert data.flags['F_CONTIGUOUS']
node_service.put_gray3D( "test_grayscale_3d", data, (0,0,0) )
retrieved_data = node_service.get_gray3D( "test_grayscale_3d", (30,31,32), (20,20,20) )
self.assertTrue( (retrieved_data == data[20:50, 20:51, 20:52]).all() )
示例4: setUpClass
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import put_gray3D [as 别名]
def setUpClass(cls):
"""
Override. Called by nosetests.
"""
# Choose names
cls.dvid_repo = "datasetA"
cls.data_name = "indices_data"
cls.volume_location = "/repos/{dvid_repo}/volumes/{data_name}".format( **cls.__dict__ )
cls.data_uuid = get_testrepo_root_uuid()
cls.node_location = "/repos/{dvid_repo}/nodes/{data_uuid}".format( **cls.__dict__ )
# Generate some test data
data = numpy.random.randint(0, 255, (1, 128, 256, 512))
data = numpy.asfortranarray(data, numpy.uint8)
cls.original_data = data
cls.voxels_metadata = VoxelsMetadata.create_default_metadata(data.shape, data.dtype, "cxyz", 1.0, "")
# Write it to a new data instance
node_service = DVIDNodeService(TEST_DVID_SERVER, cls.data_uuid)
node_service.create_grayscale8(cls.data_name)
node_service.put_gray3D( cls.data_name, data[0,...], (0,0,0) )
示例5: test_for_memory_leak
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import put_gray3D [as 别名]
def test_for_memory_leak(self):
"""
When DVIDNodeService uses array data from python or gives it to python,
it shouldn't hold on to references to that data once Python is finished with it.
Here, we use python's weakref module to see if any objects returned from
DVIDNodeService (or given to it) linger longer than they are supposed to.
"""
def get_bases(a):
"""
Return a list of all 'bases' (parents) of
the given array, including the array itself.
"""
if a is None:
return []
if not isinstance(a.base, numpy.ndarray):
return [a.base]
return [a] + get_bases(a.base)
node_service = DVIDNodeService(TEST_DVID_SERVER, self.uuid)
node_service.create_grayscale8("test_memoryleak_grayscale_3d")
data = numpy.random.randint(0, 255, (128,128,128)).astype(numpy.uint8)
assert data.flags['C_CONTIGUOUS']
w = weakref.ref(data)
node_service.put_gray3D( "test_memoryleak_grayscale_3d", data, (0,0,0) )
del data
assert w() is None, "put_gray3D() kept a reference to the data we gave it!"
retrieved_data = node_service.get_gray3D( "test_memoryleak_grayscale_3d", (128,128,128), (0,0,0) )
weak_bases = map(weakref.ref, get_bases(retrieved_data))
del retrieved_data
assert all([w() is None for w in weak_bases]), \
"Data retuned by get_gray3D() wasn't released after we deleted our reference to it!"
示例6: DVIDNodeService
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import put_gray3D [as 别名]
logging.info('UUID:\n{}'.format(uuid))
# get node service
node_service = DVIDNodeService(server_address, uuid)
# get dataset size and store in dvid
shape = image_provider.getImageShape(args.ilpFilename, args.labelImagePath)
time_range = image_provider.getTimeRange(args.ilpFilename, args.labelImagePath)
if args.timeRange is not None:
time_range = (max(time_range[0], args.timeRange[0]), min(time_range[1], args.timeRange[1]))
logging.info('Uploading time range {} to {}'.format(time_range, server_address))
keyvalue_store = "config"
node_service.create_keyvalue(keyvalue_store)
settings = { "shape": shape, "time_range": time_range }
node_service.put(keyvalue_store, "imageInfo", json.dumps(settings))
# upload all frames
for frame in range(time_range[0], time_range[1]):
logging.info("Uploading frame {}".format(frame))
label_image = image_provider.getLabelImageForFrame(args.ilpFilename, args.labelImagePath, frame)
raw_image = image_provider.getImageDataAtTimeFrame(args.rawFilename, args.rawPath, frame)
raw_name = "raw-{}".format(frame)
seg_name = "seg-{}".format(frame)
node_service.create_grayscale8(raw_name)
node_service.put_gray3D(raw_name, dataToBlock(raw_image, dtype=np.uint8), (0,0,0))
node_service.create_labelblk(seg_name)
node_service.put_labels3D(seg_name, dataToBlock(label_image, dtype=np.uint64), (0,0,0))
# TODO: upload classifier
示例7: init_dvid_database
# 需要导入模块: from libdvid import DVIDNodeService [as 别名]
# 或者: from libdvid.DVIDNodeService import put_gray3D [as 别名]
#.........这里部分代码省略.........
create_gray = 'curl -X POST 127.0.0.1:8000/api/repo/%s/instance -d'
typedata = "{\"typename\": \"uint8blk\", \"dataname\" : \"grayscale\"}"
create_gray1_command = (create_gray % uuid1).split()
create_gray1_command.append(typedata)
subprocess.check_call(create_gray1_command)
# load grayscale data
load_gray1_command = ('curl -X POST 127.0.0.1:8000/api/node/%s/grayscale/raw/0_1_2/256_256_256/0_0_0 --data-binary @%s/resources/grayscale-256-256-256-uint8.bin' % (uuid1, test_dir)).split()
subprocess.check_call(load_gray1_command)
# Grid grayscale data
# Note that the outer border is only present on
# the bottom Y-half.
#
# + + + + + <-- The '+' here are just a visual cue; they aren't in the data.
# | |
# | |
# +----+---------+----+
# | |
# | |
# | | | |
# +----+---------+----+
# | | | |
# | | | |
# +----+----+----+----+
# load grid grayscale data
grid = np.zeros( (256, 256, 256), dtype=np.uint8 )
grid[80, :, :] = 1
grid[:, 80, :] = 1
grid[:, :, 80] = 1
grid[176, :, :] = 1
grid[:, 176, :] = 1
grid[:, :, 176] = 1
shell = np.zeros( (256, 256, 256), dtype=np.uint8 )
shell[0, :, :] = 1
shell[:, 0, :] = 1
shell[:, :, 0] = 1
shell[-1, :, :] = 1
shell[:, -1, :] = 1
shell[:, :, -1] = 1
grid[:, 128:, :] |= shell[:, 128:, :]
grid *= 255
grid = 255 - grid
# Use a non-zero grayscale value
grid[grid == 0] = 1
a = vigra.filters.gaussianSmoothing(grid, 1.0)
ns = DVIDNodeService('127.0.0.1:8000', str(uuid1))
ns.create_grayscale8('grid-grayscale')
ns.put_gray3D('grid-grayscale', a, (0,0,0))
# create 256 ROI datatype
create_roi_command = ('curl -X POST 127.0.0.1:8000/api/repo/%s/instance -d' % uuid1).split()
create_roi_command.append("{\"typename\": \"roi\", \"dataname\" : \"temproi256\"}")
subprocess.check_call(create_roi_command)
# load 256 ROI
load_roi_command = ('curl -X POST 127.0.0.1:8000/api/node/%s/temproi256/roi --data-binary @%s/resources/256roi.json' % (uuid1, test_dir)).split()
subprocess.check_call(load_roi_command)
# Create ROI with missing corners
# (64px cube is missing from all 8 corners)
create_roi_command = ('curl -X POST 127.0.0.1:8000/api/repo/%s/instance -d' % uuid1).split()
create_roi_command.append("{\"typename\": \"roi\", \"dataname\" : \"roi-256-without-corners\"}")
subprocess.check_call(create_roi_command)
# load incomplete ROI
load_roi_command = ('curl -X POST 127.0.0.1:8000/api/node/%s/roi-256-without-corners/roi --data-binary @%s/resources/roi-256-without-corners.json' % (uuid1, test_dir)).split()
subprocess.check_call(load_roi_command)
# Create diagonal ROI, useful for testing stitching
_ = 0
# 8x8 blocks = 256x256 px
roi_mask_yx = np.array( [[1,_,_,_,_,_,_,1],
[1,1,_,_,_,_,1,1],
[_,1,1,_,_,1,1,_],
[_,_,1,1,1,1,_,_],
[_,_,_,1,1,_,_,_],
[_,_,1,1,1,1,_,_],
[_,1,1,_,_,1,1,_],
[1,1,_,_,_,_,1,1] ])
roi_mask_zyx = np.zeros( (8,8,8) )
roi_mask_zyx[:] = roi_mask_yx[None, :, :]
roi_block_indexes = np.transpose( roi_mask_zyx.nonzero() )
ns = DVIDNodeService('127.0.0.1:8000', str(uuid1))
ns.create_roi('diagonal-256')
ns.post_roi('diagonal-256', roi_block_indexes)
# Save the uuids to a file for debug and/or reuse
with open(uuid_file, 'w') as f:
f.write(uuid1 + '\n')
f.write(uuid2 + '\n')
return uuid1, uuid2