Giter Site home page Giter Site logo

Comments (8)

carlosuc3m avatar carlosuc3m commented on August 24, 2024 1

Hello @mkitti , I am trying to use your code and I am encountering a couple of problems.
When trying to create imglib2 images from npy files that contain 3D images the reconstruction doe snot work well. I think it is because ImgLib2 indexes flat arrays in a different way to numpy. This is why with 2D images it works well.

Is there a way to go around this problem using ImgLib2 code?

from jdll.

ctrueden avatar ctrueden commented on August 24, 2024 1

Meanwhile, pom-scijava 37.0.0 has been released and now manages imglib2 at 6.2.0...

from jdll.

mkitti avatar mkitti commented on August 24, 2024

xref: scijava/pom-scijava#229

from jdll.

carlosuc3m avatar carlosuc3m commented on August 24, 2024

Awesome, I will implement it then.
Is it possible to get a reference to the imglib2 buffer too?
Does the cursor.get().getByte() already return a reference?

from jdll.

mkitti avatar mkitti commented on August 24, 2024

I am uncertain what you mean by doss not work well.

My guess is that you need to reorder or permute the dimensions. Numpy is usually row major, and I believe imglib2 is column major.

Numpy does support Fortran order.

https://numpy.org/doc/stable/reference/generated/numpy.asfortranarray.html

You could try that. Otherwise, you will need to permite the dimensions on the ImgLib2 side.

from jdll.

carlosuc3m avatar carlosuc3m commented on August 24, 2024

This is what I was trying to refer to:

My guess is that you need to reorder or permute the dimensions. Numpy is usually row major, and I believe imglib2 is column major.

But I did not know how ImgLib2 dimensions are organised.

Permuting the axes might be the best option.
Thanks a lot @mkitti !

from jdll.

mkitti avatar mkitti commented on August 24, 2024

Numpy has dimensions (y,x) where the last dimension is the fastest varying dimension. ImgLib2 has dimensions (x,y) where the first dimension is the fastest varying dimension.

For 3D, Numpy would be (z,y,x) and ImgLib2 would be (x, y, z).

from jdll.

carlosuc3m avatar carlosuc3m commented on August 24, 2024

Finally implemented for numpy file reading. Also improved the tensor<->imglib2 RAI conversion accross all the Deep Learning engines with the help of @tpietzsch at Brno's Hackaton Oct 2023

public static <T extends NativeType<T>> RandomAccessibleInterval<T> build(ByteBuffer buf, ByteOrder byteOrder, String dtype, long[] shape, boolean fortranOrder) throws IllegalArgumentException

from jdll.

Related Issues (15)

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.