From fd9060b16ab7f1a96b23f604f3e532d921ce7cf4 Mon Sep 17 00:00:00 2001 From: Matthias Arzt Date: Thu, 27 Sep 2018 16:24:47 +0200 Subject: [PATCH 1/2] WIP: add dependency on PR https://github.com/imglib/imglib2-ij/pull/22 --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index faa2253a0..34b1472c2 100644 --- a/pom.xml +++ b/pom.xml @@ -148,6 +148,7 @@ Institute of Molecular Cell Biology and Genetics. 1.19 ${jmh.version} ${jmh.version} + 2.0.0-beta-44-SNAPSHOT From 9e6b8a2957034669d7437bf4fc63b768f6a97d5b Mon Sep 17 00:00:00 2001 From: Matthias Arzt Date: Thu, 27 Sep 2018 16:29:05 +0200 Subject: [PATCH 2/2] ImagePlusCreator: use CellImgToVirtualStack to convert CellImg to ImagePlus This speeds up the conversion of CellImg to ImagePlus. It only has an effect if the cells are planar. This is often the case when SCIFIOCellImage is used. --- .../java/net/imagej/legacy/translate/ImagePlusCreator.java | 3 +++ .../imagej/legacy/translate/ImagePlusCreatorBenchmark.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/net/imagej/legacy/translate/ImagePlusCreator.java b/src/main/java/net/imagej/legacy/translate/ImagePlusCreator.java index 9ebe64712..cebde7667 100644 --- a/src/main/java/net/imagej/legacy/translate/ImagePlusCreator.java +++ b/src/main/java/net/imagej/legacy/translate/ImagePlusCreator.java @@ -40,6 +40,7 @@ import net.imagej.display.ImageDisplay; import net.imagej.display.ImageDisplayService; import net.imglib2.img.display.imagej.ArrayImgToVirtualStack; +import net.imglib2.img.display.imagej.CellImgToVirtualStack; import net.imglib2.img.display.imagej.ImgPlusViews; import net.imglib2.img.display.imagej.ImgToVirtualStack; import net.imglib2.img.display.imagej.PlanarImgToVirtualStack; @@ -110,6 +111,8 @@ public ImagePlus createLegacyImage(final Dataset dataset, private static ImagePlus createImagePlus( Dataset dataset ) { ImgPlus< ? extends RealType< ? > > imgPlus = dataset.getImgPlus(); + if( CellImgToVirtualStack.isSupported( imgPlus ) ) + return CellImgToVirtualStack.wrap( imgPlus ); if( PlanarImgToVirtualStack.isSupported( imgPlus ) ) return PlanarImgToVirtualStack.wrap( imgPlus ); if( ArrayImgToVirtualStack.isSupported( imgPlus ) ) diff --git a/src/test/java/net/imagej/legacy/translate/ImagePlusCreatorBenchmark.java b/src/test/java/net/imagej/legacy/translate/ImagePlusCreatorBenchmark.java index 569f26e5c..e33cc54a4 100644 --- a/src/test/java/net/imagej/legacy/translate/ImagePlusCreatorBenchmark.java +++ b/src/test/java/net/imagej/legacy/translate/ImagePlusCreatorBenchmark.java @@ -77,6 +77,7 @@ public class ImagePlusCreatorBenchmark private final Dataset deepPlanarImg = makeDataset( PlanarImgs.unsignedBytes( deepDims ) ); private final Dataset small2dArrayImg = makeDataset( ArrayImgs.unsignedBytes( 10, 10 ) ); private final Dataset big2dArrayImg = makeDataset( ArrayImgs.unsignedBytes( 10000, 10000 ) ); + private final Dataset cubicCellImgWithPlanarCells = makeDataset( new CellImgFactory<>( new UnsignedByteType(), 1000, 1000, 1 ).create( cubicDims ) ); @Benchmark public void testSmallCellImg() { @@ -118,6 +119,11 @@ public void testLarge2dArrayImg() { creator.createLegacyImage( big2dArrayImg ); } + @Benchmark + public void testCubicCellImageWithPlanarCells() { + creator.createLegacyImage( cubicCellImgWithPlanarCells ); + } + private Dataset makeDataset( Img< UnsignedByteType > deepPlanarImg ) { AxisType[] axes = { Axes.X, Axes.Y, Axes.Z };