embl-cba / imagej-utils

BSD 2-Clause "Simplified" License
2 stars 4 forks source link

View Capture is slow #2

Open tischi opened 4 years ago

tischi commented 4 years ago

This is very slow! Any ideas why? The idea is to have an option in Bdv to capture the current view at a arbitrary resolution. It works, but super slow.

NicoKiaru commented 4 years ago

I've done something very similar here:

https://github.com/BIOP/bigdataviewer_scijava/blob/master/src/main/java/ch/epfl/biop/bdv/scijava/export/BDVSlicesToImgPlus.java

I think there could be many reasons for the slow behaviour:

The second point can be easily improved : just do something like a parallelstream on indices The first point can also be improved. But making it automatic is a bit annoying (compare the voxel size of the source with the one asked by the user).

If you look on my link, that's what I've done.

Regarding the third point, it's maybe the most relevant. Maybe you can split your image by block and fill the array in parallel. Personnally I used https://github.com/BIOP/bigdataviewer_scijava/blob/6f4ad5af3325e2e2de217d3ec4f421bffd8c1f17/src/main/java/ch/epfl/biop/bdv/scijava/export/BDVSlicesToImgPlus.java#L197

But I think it's not parallel. (Bdv is retrieving the data in parallel) And is sometimes terribly slow.

tischi commented 4 years ago

you take the full resolution source (may be there are mipmaps)

Veeeery good point! I could have bet I find the most appropriate resolution already, but apparently I use the highest. Very dumb. I think that will help a lot!

tischi commented 4 years ago

@NicoKiaru Do you have code to programmatically generate a source with more then 1 level? I would need this for testing. I know things like below but they only create one level:

final RandomAccessibleIntervalSource< ? > source = new RandomAccessibleIntervalSource( rai, Util.getTypeFromInterval( rai ), "image" );
tischi commented 4 years ago

Works now much faster!

https://github.com/tischi/bdv-utils/blob/render/src/main/java/de/embl/cba/bdv/utils/capture/BdvViewCaptures.java#L86

tpietzsch commented 4 years ago

Also have a look at https://github.com/bigdataviewer/bigdataviewer-core/blob/18e7fc18647e0e13344460f3f169825594b13a20/src/main/java/bdv/tools/RecordMovieDialog.java#L256-L318

tischi commented 4 years ago

Thanks! In fact this was the first thing I looked at, but frankly I had trouble understanding it enough to make it it work for me, in terms of:

  1. Specify a specific output voxel size
  2. Have output as an IJ1 CompositeImage such that people can still play around this the LUTs