当前位置:网站首页>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)
边栏推荐
- Opencv learning log 19 skin grinding
- Nodejs crawler
- 读取和保存zarr文件
- Opencv learning log 18 Canny operator
- 【练习-9】Zombie’s Treasure Chest
- Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
- 【练习-7】(Uva 10976)Fractions Again?!(分数拆分)
- 渗透测试 ( 8 ) --- Burp Suite Pro 官方文档
- 最全编程语言在线 API 文档
- Gartner: five suggestions on best practices for zero trust network access
猜你喜欢
随机推荐
分享一个在树莓派运行dash应用的实例。
树莓派4B安装opencv3.4.0
Penetration test (1) -- necessary tools, navigation
1689. Ten - the minimum number of binary numbers
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
b站 实时弹幕和历史弹幕 Protobuf 格式解析
1323. Maximum number of 6 and 9
双向链表—全部操作
渗透测试 ( 7 ) --- 漏洞扫描工具 Nessus
渗透测试 ( 3 ) --- Metasploit Framework ( MSF )
Nodejs+vue网上鲜花店销售信息系统express+mysql
Penetration test (3) -- Metasploit framework (MSF)
【练习-3】(Uva 442)Matrix Chain Multiplication(矩阵链乘)
Interval sum ----- discretization
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
PySide6 信号、槽
C language is the watershed between low-level and high-level
Basic Q & A of introductory C language
Opencv learning log 30 -- histogram equalization
Nodejs+vue online fresh flower shop sales information system express+mysql