From 3b071befbf5b8c6380ac78d40fe31a95c74048cf Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Thu, 29 Feb 2024 13:03:02 -0500 Subject: [PATCH] DoG detection takes RandomAccessible's instead of RandomAccessibleInterval's (so OutOfBounds - or not - can be defined outside) --- .../imgloaders/LegacyDHMImgLoader.java | 5 +-- .../LegacyFileMapImgLoaderLOCI.java | 5 +-- .../LegacyLightSheetZ1ImgLoader.java | 4 +- .../LegacyMicroManagerImgLoader.java | 4 +- .../imgloaders/LegacyStackImgLoaderIJ.java | 4 +- .../imgloaders/LegacyStackImgLoaderLOCI.java | 4 +- .../imgloaders/SimViewSetupImgLoader.java | 4 +- .../filemap2/FileMapImgLoaderLOCI2.java | 4 +- .../SplitMultiResolutionSetupImgLoader.java | 2 +- .../splitting/SplitSetupImgLoader.java | 2 +- .../splitting/SplitViewerSetupImgLoader.java | 4 +- .../methods/dog/DoG.java | 9 ++-- .../methods/dog/DoGImgLib2.java | 43 +++++++++---------- src/main/java/util/ImgLib2Tools.java | 28 ++++++++---- 14 files changed, 67 insertions(+), 55 deletions(-) diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyDHMImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyDHMImgLoader.java index 6991d24dd..6119fc9a1 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyDHMImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyDHMImgLoader.java @@ -31,7 +31,6 @@ import ij.io.Opener; import mpicbg.spim.data.generic.sequence.AbstractSequenceDescription; import mpicbg.spim.data.generic.sequence.BasicViewDescription; -import mpicbg.spim.data.generic.sequence.BasicViewSetup; import mpicbg.spim.data.sequence.Channel; import mpicbg.spim.data.sequence.ViewId; import mpicbg.spim.data.sequence.VoxelDimensions; @@ -98,9 +97,9 @@ public LegacyDHMImgLoader( public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize ) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( view ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( view ) ); else - return ImgLib2Tools.convertVirtual( getImage( view ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( view ) ); } @Override diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyFileMapImgLoaderLOCI.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyFileMapImgLoaderLOCI.java index 458c31c46..9c2bdfb16 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyFileMapImgLoaderLOCI.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyFileMapImgLoaderLOCI.java @@ -61,7 +61,6 @@ import net.imglib2.IterableInterval; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.Img; -import net.imglib2.img.ImgFactory; import net.imglib2.img.array.ArrayImg; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; @@ -139,9 +138,9 @@ public LegacyFileMapImgLoaderLOCI( public RandomAccessibleInterval< FloatType > getFloatImage(ViewId view, boolean normalize) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( view ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( view ) ); else - return ImgLib2Tools.convertVirtual( getImage( view ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( view ) ); } diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyLightSheetZ1ImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyLightSheetZ1ImgLoader.java index f32743ded..db59be209 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyLightSheetZ1ImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyLightSheetZ1ImgLoader.java @@ -86,9 +86,9 @@ public LegacyLightSheetZ1ImgLoader( public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize ) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( view ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( view ) ); else - return ImgLib2Tools.convertVirtual( getImage( view ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( view ) ); } @Override diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyMicroManagerImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyMicroManagerImgLoader.java index 6af2d5852..fbcd02125 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyMicroManagerImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyMicroManagerImgLoader.java @@ -121,9 +121,9 @@ final public static < T extends RealType< T > & NativeType< T > > void populateI public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize ) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( view ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( view ) ); else - return ImgLib2Tools.convertVirtual( getImage( view ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( view ) ); } @Override diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderIJ.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderIJ.java index b4ff2431b..0dac97a27 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderIJ.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderIJ.java @@ -91,9 +91,9 @@ public static ImagePlus open( File file ) public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize ) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( view ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( view ) ); else - return ImgLib2Tools.convertVirtual( getImage( view ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( view ) ); } /** diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderLOCI.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderLOCI.java index 0ed9b9d9d..eb5b108c7 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderLOCI.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/LegacyStackImgLoaderLOCI.java @@ -82,9 +82,9 @@ public LegacyStackImgLoaderLOCI( public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize ) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( view ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( view ) ); else - return ImgLib2Tools.convertVirtual( getImage( view ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( view ) ); } /** diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/SimViewSetupImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/SimViewSetupImgLoader.java index 136d76d94..dc725c659 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/SimViewSetupImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/SimViewSetupImgLoader.java @@ -88,9 +88,9 @@ public SimViewSetupImgLoader( public RandomAccessibleInterval getFloatImage( final int timepointId, final boolean normalize, ImgLoaderHint... hints ) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( timepointId, hints ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( timepointId, hints ) ); else - return ImgLib2Tools.convertVirtual( getImage( timepointId, hints ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( timepointId, hints ) ); } @Override diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/filemap2/FileMapImgLoaderLOCI2.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/filemap2/FileMapImgLoaderLOCI2.java index 30ba01e93..23d6c57cb 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/filemap2/FileMapImgLoaderLOCI2.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/filemap2/FileMapImgLoaderLOCI2.java @@ -220,9 +220,9 @@ public RandomAccessibleInterval< FloatType > getFloatImage(int timepointId, bool ImgLoaderHint... hints) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( timepointId, hints ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( timepointId, hints ) ); else - return ImgLib2Tools.convertVirtual( getImage( timepointId, hints ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( timepointId, hints ) ); } @Override diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitMultiResolutionSetupImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitMultiResolutionSetupImgLoader.java index 33ee2e883..fe2a3d86f 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitMultiResolutionSetupImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitMultiResolutionSetupImgLoader.java @@ -96,7 +96,7 @@ public RandomAccessibleInterval< FloatType > getFloatImage( final int timepointI // TODO: this is stupid, remove capablitity to get FloatType images! if ( normalize ) { - return ImgLib2Tools.normalizeVirtual( img ); + return ImgLib2Tools.normalizeVirtualRAI( img ); } else { diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitSetupImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitSetupImgLoader.java index 4b095eeb9..6e21f9d5f 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitSetupImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitSetupImgLoader.java @@ -70,7 +70,7 @@ public RandomAccessibleInterval< FloatType > getFloatImage( final int timepointI // TODO: this is stupid, remove capablitity to get FloatType images! if ( normalize ) { - return ImgLib2Tools.normalizeVirtual( img ); + return ImgLib2Tools.normalizeVirtualRAI( img ); } else { diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitViewerSetupImgLoader.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitViewerSetupImgLoader.java index fae8fa33c..2641a7a23 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitViewerSetupImgLoader.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/splitting/SplitViewerSetupImgLoader.java @@ -156,9 +156,9 @@ public UnsignedShortType getImageType() public RandomAccessibleInterval< FloatType > getFloatImage( final int timepointId, final boolean normalize, final ImgLoaderHint... hints ) { if ( normalize ) - return ImgLib2Tools.normalizeVirtual( getImage( timepointId, hints ) ); + return ImgLib2Tools.normalizeVirtualRAI( getImage( timepointId, hints ) ); else - return ImgLib2Tools.convertVirtual( getImage( timepointId, hints ) ); + return ImgLib2Tools.convertVirtualRAI( getImage( timepointId, hints ) ); } @Override diff --git a/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoG.java b/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoG.java index e7732b028..3793b6e7c 100644 --- a/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoG.java +++ b/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoG.java @@ -29,6 +29,7 @@ import ij.IJ; import mpicbg.spim.data.sequence.ViewDescription; import mpicbg.spim.data.sequence.ViewId; +import net.imglib2.FinalInterval; import net.imglib2.RandomAccessibleInterval; import net.imglib2.realtransform.AffineTransform3D; import net.imglib2.type.NativeType; @@ -60,7 +61,7 @@ public static HashMap< ViewId, List< InterestPoint >> findInterestPoints( final return interestPoints; } - /** + /* * finds all interest points and returns them as InterestPoints (which is a mpicbg Point and implements RealLocalizable), * by default returns world coordinates * @@ -92,8 +93,9 @@ public static < T extends RealType< T > & NativeType< T > > List< InterestPoint // compute Difference-of-Gaussian (includes normalization) // List< InterestPoint > ips = DoGImgLib2.computeDoG( - Views.zeroMin( input ), + Views.extendMirrorSingle( Views.zeroMin( input ) ), null, + new FinalInterval( Views.zeroMin( input ) ), sigma, threshold, 1, // 0 = no subpixel localization, 1 = quadratic fit @@ -150,8 +152,9 @@ public static void addInterestPoints( final HashMap< ViewId, List< InterestPoint @SuppressWarnings("unchecked") List< InterestPoint > ips = DoGImgLib2.computeDoG( - input.getA(), + Views.extendMirrorSingle( input.getA() ), null, // mask + new FinalInterval( input.getA() ), dog.sigma, dog.threshold, dog.localization, diff --git a/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoGImgLib2.java b/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoGImgLib2.java index a8d0e99f2..f8200ebbc 100644 --- a/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoGImgLib2.java +++ b/src/main/java/net/preibisch/mvrecon/process/interestpointdetection/methods/dog/DoGImgLib2.java @@ -53,11 +53,9 @@ import net.imglib2.img.array.ArrayImg; import net.imglib2.img.array.ArrayImgFactory; import net.imglib2.img.array.ArrayImgs; -import net.imglib2.img.basictypeaccess.AccessFlags; import net.imglib2.img.basictypeaccess.array.FloatArray; import net.imglib2.img.cell.CellImgFactory; import net.imglib2.img.display.imagej.ImageJFunctions; -import net.imglib2.type.NativeType; import net.imglib2.type.Type; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.FloatType; @@ -82,7 +80,6 @@ import net.preibisch.mvrecon.process.interestpointdetection.methods.lazygauss.LazyGauss; import net.preibisch.mvrecon.process.interestpointdetection.methods.lazygauss.LazyWeightedGauss; import util.ImgLib2Tools; -import util.Lazy; public class DoGImgLib2 { @@ -112,7 +109,7 @@ public static void main ( String[] args ) // 1388x1040x81 = 116925120 final ArrayList points = - computeDoG(inputCropped, null, 2.000, 0.03, 1/*localization*/, false /*findMin*/, true /*findMax*/, 0, 255, Executors.newFixedThreadPool( 8 ) ); + computeDoG( Views.extendMirrorDouble( inputCropped ), Views.extendZero( mask ), new FinalInterval( inputCropped ), 2.000, 0.03, 1/*localization*/, false /*findMin*/, true /*findMax*/, 0, 255, Executors.newFixedThreadPool( 8 ) ); System.out.println( System.currentTimeMillis() - time ); @@ -141,8 +138,9 @@ public static < T extends RealType< T > > int radiusDoG( final double sigma ) } public static < T extends RealType< T > > ArrayList< InterestPoint > computeDoG( - final RandomAccessibleInterval< T > input, - final RandomAccessibleInterval< T > mask, + final RandomAccessible< T > input, + final RandomAccessible< T > mask, + final Interval interval, final double sigma, final double threshold, final int localization, @@ -152,12 +150,13 @@ public static < T extends RealType< T > > ArrayList< InterestPoint > computeDoG( final double maxIntensity, final ExecutorService service ) { - return computeDoG(input, mask, sigma, threshold, localization, findMin, findMax, minIntensity, maxIntensity, blockSize, service, null, null, false, 0.0 ); + return computeDoG(input, mask, interval, sigma, threshold, localization, findMin, findMax, minIntensity, maxIntensity, blockSize, service, null, null, false, 0.0 ); } public static < T extends RealType< T > > ArrayList< InterestPoint > computeDoG( - final RandomAccessibleInterval< T > input, - final RandomAccessibleInterval< T > mask, + final RandomAccessible< T > input, + final RandomAccessible< T > mask, + final Interval interval, final double sigma, final double threshold, final int localization, @@ -189,9 +188,9 @@ public static < T extends RealType< T > > ArrayList< InterestPoint > computeDoG( final float[] minmax; if ( mask == null ) - minmax = FusionTools.minMax( input, service ); + minmax = FusionTools.minMax( Views.interval( input, interval ), service ); else - minmax = minMax( input, mask, service ); + minmax = minMax( Views.interval( input, interval ), Views.interval( mask, interval ), service ); min = minmax[ 0 ]; max = minmax[ 1 ]; @@ -206,7 +205,7 @@ public static < T extends RealType< T > > ArrayList< InterestPoint > computeDoG( IOFunctions.println( "(" + new Date(System.currentTimeMillis()) + "): min intensity = " + min + ", max intensity = " + max ); // normalize image - final RandomAccessibleInterval< FloatType > inputFloat = ImgLib2Tools.normalizeVirtual( input, min, max ); + final RandomAccessible< FloatType > inputFloat = ImgLib2Tools.normalizeVirtual( input, min, max ); final float k = LaPlaceFunctions.computeK( 4 ); final float K_MIN1_INV = LaPlaceFunctions.computeKWeight(k); @@ -232,10 +231,10 @@ public static < T extends RealType< T > > ArrayList< InterestPoint > computeDoG( "threshold=" + minPeakValue + ", sigma1=" + Util.printCoordinates( sigma1 ) + ", sigma2=" + Util.printCoordinates( sigma2 ) + ")" ); final long[] minInterval = new long[ inputFloat.numDimensions() ]; - inputFloat.min( minInterval ); + interval.min( minInterval ); final RandomAccessibleInterval< FloatType > gauss1, gauss2; - final RandomAccessibleInterval< FloatType > maskFloat; + final RandomAccessible< FloatType > maskFloat; if ( mask == null ) { @@ -243,22 +242,22 @@ public static < T extends RealType< T > > ArrayList< InterestPoint > computeDoG( if ( cuda == null ) { - gauss1 = LazyGauss.init( Views.extendMirrorDouble( inputFloat ), new FinalInterval( inputFloat ), new FloatType(), sigma1, blockSize ); - gauss2 = LazyGauss.init( Views.extendMirrorDouble( inputFloat ), new FinalInterval( inputFloat ), new FloatType(), sigma2, blockSize ); + gauss1 = LazyGauss.init( inputFloat, interval, new FloatType(), sigma1, blockSize ); + gauss2 = LazyGauss.init( inputFloat, interval , new FloatType(), sigma2, blockSize ); } else { // TODO: untested - gauss1 = computeGaussCUDA( inputFloat, sigma1, cuda, cudaDevice, accurateCUDA, percentGPUMem ); - gauss2 = computeGaussCUDA( inputFloat, sigma2, cuda, cudaDevice, accurateCUDA, percentGPUMem ); + gauss1 = computeGaussCUDA( Views.interval( inputFloat, interval ), sigma1, cuda, cudaDevice, accurateCUDA, percentGPUMem ); + gauss2 = computeGaussCUDA( Views.interval( inputFloat, interval ), sigma2, cuda, cudaDevice, accurateCUDA, percentGPUMem ); } } else { - maskFloat = Converters.convertRAI( mask, (i,o) -> o.set( i.getRealFloat() ), new FloatType());//ImgLib2Tools.convertVirtual( mask ); + maskFloat = Converters.convert( mask, (i,o) -> o.set( i.getRealFloat() ), new FloatType());//ImgLib2Tools.convertVirtual( mask ); - gauss1 = LazyWeightedGauss.init( Views.extendMirrorSingle( inputFloat ), Views.extendZero( maskFloat ), new FinalInterval( inputFloat ), new FloatType(), sigma1, blockSize ); - gauss2 = LazyWeightedGauss.init( Views.extendMirrorSingle( inputFloat ), Views.extendZero( maskFloat ), new FinalInterval( inputFloat ), new FloatType(), sigma2, blockSize ); + gauss1 = LazyWeightedGauss.init( inputFloat, maskFloat, interval, new FloatType(), sigma1, blockSize ); // mask zero oobs + gauss2 = LazyWeightedGauss.init( inputFloat, maskFloat, interval, new FloatType(), sigma2, blockSize ); } final RandomAccessibleInterval< FloatType > dog = Converters.convert(gauss2, gauss1, new BiConverter() @@ -277,7 +276,7 @@ public void convert( final FloatType inputA, final FloatType inputB, final Float if ( !silent ) IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Detecting peaks." ); - final ArrayList< SimplePeak > peaks = findPeaks( dogCached, maskFloat, minInitialPeakValue, service ); + final ArrayList< SimplePeak > peaks = findPeaks( dogCached, Views.interval( maskFloat, interval ), minInitialPeakValue, service ); if ( !silent ) IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Found " + peaks.size() + " initial peaks (before refinement)." ); diff --git a/src/main/java/util/ImgLib2Tools.java b/src/main/java/util/ImgLib2Tools.java index 996d2602e..75d596845 100644 --- a/src/main/java/util/ImgLib2Tools.java +++ b/src/main/java/util/ImgLib2Tools.java @@ -22,6 +22,7 @@ */ package util; +import net.imglib2.RandomAccessible; import net.imglib2.RandomAccessibleInterval; import net.imglib2.converter.Converters; import net.imglib2.type.numeric.RealType; @@ -30,17 +31,28 @@ public class ImgLib2Tools { - public static final < T extends RealType< T > > RandomAccessibleInterval convertVirtual( final RandomAccessibleInterval< T > img ) + public static final < T extends RealType< T > > RandomAccessibleInterval convertVirtualRAI( final RandomAccessibleInterval< T > img ) { return Converters.convertRAI( img, (i,o) -> o.set( i.getRealFloat() ), new FloatType()); - /* - return new ConvertedRandomAccessibleInterval( + } + + public static final < T extends RealType< T > > RandomAccessible convertVirtual( final RandomAccessible< T > img ) + { + return Converters.convert( img, (i,o) -> o.set( i.getRealFloat() ), new FloatType()); + } + + public static final < T extends RealType< T > > RandomAccessible normalizeVirtual( final RandomAccessible< T > img, final double min, final double max ) + { + final float minf = (float)min; + final float maxf = (float)max; + + return Converters.convert( img, - new RealFloatConverter(), - new FloatType() );*/ + ( input, output ) -> output.set( ( input.getRealFloat() - minf ) / ( maxf - minf ) ), + new FloatType() ); } - public static final < T extends RealType< T > > RandomAccessibleInterval normalizeVirtual( final RandomAccessibleInterval< T > img, final double min, final double max ) + public static final < T extends RealType< T > > RandomAccessibleInterval normalizeVirtualRAI( final RandomAccessibleInterval< T > img, final double min, final double max ) { final float minf = (float)min; final float maxf = (float)max; @@ -51,7 +63,7 @@ public static final < T extends RealType< T > > RandomAccessibleInterval > RandomAccessibleInterval normalizeVirtual( final RandomAccessibleInterval< T > img ) + public static final < T extends RealType< T > > RandomAccessibleInterval normalizeVirtualRAI( final RandomAccessibleInterval< T > img ) { double min = Double.MAX_VALUE; double max = -Double.MAX_VALUE; @@ -67,6 +79,6 @@ public static final < T extends RealType< T > > RandomAccessibleInterval