Coder Social home page Coder Social logo

Comments (25)

jni avatar jni commented on April 30, 2024 1

Haha I use TIFFs for such data all the time. They have some compression support, but I don't know anything about its performance in comparison to other options. TIFF also has vast metadata capabilities, although see my upcoming comment in #263 for caveats.

from imageio.

ghisvail avatar ghisvail commented on April 30, 2024

Do you have a link for these claims ? (I was personally not aware of it)

Is that something that cannot be fixed upstream, instead of re-inventing a new format for data serialization ?

from imageio.

almarklein avatar almarklein commented on April 30, 2024

I tried NPZ in pypy and it simply was not implemented. In Vispy we've had some trouble with data stored in npz files. It seemed that with a certain combination of Python2 and Numpy the file could not be read in Python3.

The title could also be: implement plugins for other (existing) 3D data formats.

from imageio.

ghisvail avatar ghisvail commented on April 30, 2024

Do you have specific formats in mind ?

from imageio.

almarklein avatar almarklein commented on April 30, 2024

In particular MHD (#29) and hdf5. However, the first needs 2 files to store data (bah) and I suspect hdf5 wont work without relying on another library ...

from imageio.

ghisvail avatar ghisvail commented on April 30, 2024

Actually, dual-file data storage is still pretty common. Most of the proprietary formats I deal with in my research are designed that way (one file for the descriptor, one for the raw data). So I'd be interested to see how you are planning to wrap that out.

For HDF5, which I am also familiar with, pytables and h5py are already decent solutions around libhdf5. I don't know whether there is a niche for a pure-Python implementation of it though.

from imageio.

rossant avatar rossant commented on April 30, 2024

For HDF5, just stick with h5py...

from imageio.

rossant avatar rossant commented on April 30, 2024

About npz: it looks like there are no problems when files are created in Python 3 (see this issue). Is it conceivable to just throw a big warning when users save npz files in Python 2? Python 3 users will probably never have a problem. It might just be a matter of mentioning this potential problem in the documentation.

from imageio.

almarklein avatar almarklein commented on April 30, 2024

As for hdf5, imageio could provide a thin wrapper to easy the storing and retrieving of image/volume data. Not sure if this is at all useful; it might already be simple enough with pytables/h5py.

Still, I'd like to have something that is pure Python (i.e. works everywhere) and does not rely on another lib...

from imageio.

rossant avatar rossant commented on April 30, 2024

I agree that a pure Python HDF5 lib might be useful generally speaking, but it might be a lot of work. In my experience the HDF5 C API is horrible to work on, even just getting the data can be quite complicated...

Also, anyone willing to work with HDF5 files in Python will always have h5py or pytables installed. (they are installed by default in anaconda for example)

from imageio.

almarklein avatar almarklein commented on April 30, 2024

I agree, but I was not talking of hdf5 per see.

from imageio.

rossant avatar rossant commented on April 30, 2024

@almarklein then I think you have too options:

  • npz/npy
  • flat binary + metadata (either in a header, or in a second file)

from imageio.

almarklein avatar almarklein commented on April 30, 2024

npz is not widely available (it depends on numpy and is not available on pypy). I think I can do better than a flat binary with meta data :) Would be best if there was already a format that we could use. If not, I might just implement something simple.

from imageio.

rossant avatar rossant commented on April 30, 2024

Oh so you really mean pure Python (no NumPy etc)? Just out of curiosity, why do you need PyPy support?

How can you do best and simpler than flat+header in pure Python?

from imageio.

almarklein avatar almarklein commented on April 30, 2024

I just hate it that we cannot do volumes in pypy :)

from imageio.

almarklein avatar almarklein commented on April 30, 2024

Reopening. I'm thinking of something pure Python (not relying on simpleITK), or more generic (preferably both).

from imageio.

ghisvail avatar ghisvail commented on April 30, 2024

Have you looked into the formats that OpenImageIO supports for inspiration?

from imageio.

almarklein avatar almarklein commented on April 30, 2024

I did now. But their plugins that support volumetric images are either based on hdf5 or aimed very much on animation.

from imageio.

dimatura avatar dimatura commented on April 30, 2024

There's the nrrd format, which is quite simple (basically flat binary, optionally compressed): http://teem.sourceforge.net/nrrd/
I've used the pure python (with numpy) implementation here: https://github.com/mhe/pynrrd/blob/master/nrrd.py

from imageio.

almarklein avatar almarklein commented on April 30, 2024

Thanks @dimatura that sounds interesting, especially since its pure Python

from imageio.

jni avatar jni commented on April 30, 2024

@almarklein why has TIFF not been discussed here? iirc TiffFile has a pure python implementation...?

from imageio.

almarklein avatar almarklein commented on April 30, 2024

Would TIFF be suited for storing a 512x512x512 volume? I've never seen people do that with GIF, perhaps because the compression is not that good?

In some cases it would also be necessary to store meta data like spacing between voxels, the origin, or a transformation matrix.

from imageio.

almarklein avatar almarklein commented on April 30, 2024

Fair enough :) The Tiff format recently became 3D capable by supporting volread(). My impression was that this was mostly to read all channels at once, but it can indeed also be used to store actual volumetric data.

from imageio.

almarklein avatar almarklein commented on April 30, 2024

Maybe this is why Tiff, although 3D capable, is a bit hard to sell as the format for 3D data: #263 (comment) :)

from imageio.

jni avatar jni commented on April 30, 2024

🏳️

from imageio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.