当前位置:网站首页>Read and save zarr files
Read and save zarr files
2022-07-06 16:10:00 【Little Aries in the mountains】
Preface
zarr A data format , and hdf The file is a bit similar , That is, a file can contain many different dataset
And hdf Different documents , Intuitively hdf It's a single file , and zarr It's a folder , It also contains different subfolders ( amount to hdf Medium dataset), Data is stored under the subfolder
Another point ,zarr Save data in blocks , Frankly speaking , It is to divide a whole block of data into sub blocks of the same size , Each sub block is saved as a file , Name it *.*.*, The advantage of this processing is that it is very friendly to large-scale medical images
There are also two special files .zarray and .zattrs, There are data characteristics, size information and so on , for example
.zarray
.zattrs
Read
import zarr
import numpy as np
input_name = 'data.zarr'
dataset_name = 'volumes/raw'
f = zarr.open(input_name)
raw = f[dataset_name ]
print(raw.shape)
raw_data = raw[:]
preservation
import zarr
import numpy as np
output_name = 'data.zarr'
dataset_name = 'volumes/raw'
root = zarr.open(output_name , mode='a')
shape = [1000, 1000, 1000] # Size of the entire data ,3D
chunk_size = [128, 128, 128] # The size of the blocks
dtype = np.uint8 # data type
compressor = {
'id': 'gzip', 'level': 5}
compressor = zarr.get_codec(compressor) # Compression way
dataset_name = dataset_name.lstrip('/')
ds = root.create_dataset(
dataset_name,
shape=shape,
chunks=chunk_size,
dtype=dtype,
compressor=compressor)
ds.attrs['resolution'] = [8, 8, 8]
ds.attrs['offset'] = [0, 0, 0]
ds[:] = np.ones(tuple(shape), dtype=dtype)
边栏推荐
- 信息安全-史诗级漏洞Log4j的漏洞机理和防范措施
- [exercise-7] crossover answers
- 树莓派CSI/USB摄像头使用mjpg实现网页摄像头监控
- 信息安全-安全编排自动化与响应 (SOAR) 技术解析
- 渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
- Opencv learning log 19 skin grinding
- b站 實時彈幕和曆史彈幕 Protobuf 格式解析
- 【练习-6】(PTA)分而治之
- “鬼鬼祟祟的”新小行星将在本周安全掠过地球:如何观看
- Penetration test (7) -- vulnerability scanning tool Nessus
猜你喜欢
Gartner:关于零信任网络访问最佳实践的五个建议
Information security - threat detection - detailed design of NAT log access threat detection platform
X-Forwarded-For详解、如何获取到客户端IP
渗透测试 ( 3 ) --- Metasploit Framework ( MSF )
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
C language must memorize code Encyclopedia
信息安全-威胁检测-flink广播流BroadcastState双流合并应用在过滤安全日志
渗透测试 ( 1 ) --- 必备 工具、导航
Configuration du cadre flask loguru log Library
【高老师UML软件建模基础】20级云班课习题答案合集
随机推荐
Penetration test (3) -- Metasploit framework (MSF)
Programmers, what are your skills in code writing?
Opencv learning log 15 count the number of solder joints and output
Penetration test (1) -- necessary tools, navigation
【高老师软件需求分析】20级云班课习题答案合集
Gartner:关于零信任网络访问最佳实践的五个建议
【练习-9】Zombie’s Treasure Chest
“鬼鬼祟祟的”新小行星将在本周安全掠过地球:如何观看
信息安全-安全编排自动化与响应 (SOAR) 技术解析
Ball Dropping
Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
What is the difficulty of programming?
1855. Maximum distance of subscript alignment
Interval sum ----- discretization
Sanic异步框架真的这么强吗?实践中找真理
C language must memorize code Encyclopedia
Opencv learning log 26 -- detect circular holes and mark them
【练习-7】Crossword Answers