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 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 };