- Notifications
You must be signed in to change notification settings - Fork28
xtensor plugin to read and write images, audio files, numpy (compressed) npz and HDF5
License
xtensor-stack/xtensor-io
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Reading and writing image, sound and npz file formats to and from xtensor data structures.
Try it live in the browser!
xtensor-io offers an API to read and write various file formats intoxtensor data structures:
- images,
- audio files,
- NumPy's compressed storage format (NPZ),
- HDF5 files,
- Blosc.
xtensor-io wraps theOpenImageIO,libsndfile,zlib,HighFive, andblosc libraries.
xtensor-io is a header-only library. We provide a package for the mamba (or conda) package manager.
mamba install xtensor-io -c conda-forge
xtensor-iodepends onxtensor^0.25.0.OpenImageIO,libsndfile,zlib,HighFive, andbloscare optional dependencies toxtensor-ioOpenImageIOis required to read and write image files.libsndfileis required to read and write sound files.zlibis required to load NPZ files.HighFive(and theHDF5library) is required to read and write HDF5 files.bloscis required to read and write Blosc files.
All five libraries are available for the conda package manager.
You can also installxtensor-io from source:
mkdir buildcd buildcmake ..makesudo make installTo try out xtensor-io interactively in your web browser, just click on the binderlink:
To get started with usingxtensor-io, check out the full documentation
http://xtensor-io.readthedocs.io/
// loads png image into xarray with shape HEIGHT x WIDTH x CHANNELSauto img_arr = xt::load_image("test.png");// write xarray out to JPEG imagext::dump_image("dumptest.jpg", img_arr +5);// load npz file containing multiple arraysauto npy_map = xt::load_npz("test.npz");auto arr_0 = npy_map["arr_0"].cast<double>();auto arr_1 = npy_map["arr_1"].cast<unsignedlong>();// open a wav fileauto audio = xt::load_audio("files/xtensor.wav");auto& audio_arr = std::get<1>(audio);// audio contents (like scipy.io.wavfile results)// save a sine wave soundint freq =2000;int sampling_freq =44100;double duration =1.0;auto t = xt::arange(0.0, duration,1.0 / sampling_freq);auto y = xt::sin(2.0 * xt::numeric_constants<double>::PI * freq * t);xt::dump_audio("files/sine.wav", y, sampling_freq);
We use a shared copyright model that enables all contributors to maintain thecopyright on their contributions.
This software is licensed under the BSD-3-Clause license. See theLICENSE file for details.
About
xtensor plugin to read and write images, audio files, numpy (compressed) npz and HDF5
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors15
Uh oh!
There was an error while loading.Please reload this page.