From b1a2b0374b08ac2339d69d44051565adb11f2a71 Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Tue, 24 Sep 2024 14:45:06 -0400 Subject: [PATCH] fix compile error (I hope) --- .../alignment/mapper/SingleChannelMapper.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/render-app/src/main/java/org/janelia/alignment/mapper/SingleChannelMapper.java b/render-app/src/main/java/org/janelia/alignment/mapper/SingleChannelMapper.java index 9595aa61b..da3b82214 100644 --- a/render-app/src/main/java/org/janelia/alignment/mapper/SingleChannelMapper.java +++ b/render-app/src/main/java/org/janelia/alignment/mapper/SingleChannelMapper.java @@ -41,7 +41,9 @@ public class SingleChannelMapper final AffineTransform2D t, tInv; final double[] tmp; + // 2x2 subsampling using bottom-right pixels final int subsampling = 2; + final long[] offset = new long[] { -1, -1 }; public SingleChannelMapper(final ImageProcessorWithMasks source, final ImageProcessorWithMasks target, @@ -59,7 +61,7 @@ public SingleChannelMapper(final ImageProcessorWithMasks source, //this.access = rra.realRandomAccess(); this.tmp = new double[ 2 ]; - this.rra = createSubsampled( img, subsampling ); + this.rra = createSubsampled( img, subsampling, offset ); this.access = rra.realRandomAccess(); // transform to undo the subsampling @@ -69,17 +71,25 @@ public SingleChannelMapper(final ImageProcessorWithMasks source, } else { - throw new RuntimeException( "not supported for subsampling" ); + this.t = this.tInv = null; + this.img = null; + this.rra = null; + this.access = null; + this.tmp = null; + //throw new RuntimeException( "not supported for subsampling" ); } } // TOOD: remove synchronized (just there so it is shown once for testing) - public static RealRandomAccessible createSubsampled( final Img img, final int subsampling ) + public static RealRandomAccessible createSubsampled( final Img img, final int subsampling, final long[] offset ) { + // change which pixel in the local neighborhood is being used + final RandomAccessibleInterval imgTranslated = Views.interval( Views.extendBorder( Views.translate( img, offset ) ), img ); + // right now always takes the first pixel // to do advanced types of downsampling we need to implement our own version of net.imglib2.view.SubsampleIntervalView / net.imglib2.view.SubsampleView // to use e.g. the center pixel for 3x3, we simply need to translate the underlying img - final RandomAccessibleInterval sub = Views.subsample( img, subsampling ); + final RandomAccessibleInterval sub = Views.subsample( imgTranslated, subsampling ); // bordering is necessary so the interpolation on the smaller image does not create black borders final RealRandomAccessible rraSub = Views.interpolate( Views.extendBorder( sub ), new NLinearInterpolatorFactory<>() );