From f2c24859747db70f6858e976a816a52e9eb00ea3 Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Fri, 10 May 2024 10:49:51 -0400 Subject: [PATCH] fix bug if #tiles=2 for optimizing splitting --- .../process/splitting/SplittingTools.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/preibisch/mvrecon/process/splitting/SplittingTools.java b/src/main/java/net/preibisch/mvrecon/process/splitting/SplittingTools.java index a36049aa..10d61a8a 100644 --- a/src/main/java/net/preibisch/mvrecon/process/splitting/SplittingTools.java +++ b/src/main/java/net/preibisch/mvrecon/process/splitting/SplittingTools.java @@ -365,6 +365,7 @@ public static ArrayList< Interval > distributeIntervalsFixedOverlap( final Inter if ( lastImageSize <= s / 2 ) { // increase image size until lastImageSize goes towards zero, then large + System.out.println( "small" ); do { @@ -373,7 +374,7 @@ public static ArrayList< Interval > distributeIntervalsFixedOverlap( final Inter delta = lastImageSize - currentLastImageSize; lastImageSize = currentLastImageSize; - //System.out.println( lastSize + ": " + lastImageSize + ", delta=" + delta ); + System.out.println( lastSize + ": " + lastImageSize + ", delta=" + delta ); } while ( delta > 0 ); @@ -382,6 +383,7 @@ public static ArrayList< Interval > distributeIntervalsFixedOverlap( final Inter else { // decrease image size until lastImageSize is maximal + System.out.println( "large" ); do { @@ -390,7 +392,7 @@ public static ArrayList< Interval > distributeIntervalsFixedOverlap( final Inter delta = lastImageSize - currentLastImageSize; lastImageSize = currentLastImageSize; - //System.out.println( lastSize + ": " + lastImageSize + ", delta=" + delta ); + System.out.println( lastSize + ": " + lastImageSize + ", delta=" + delta ); } while ( delta < 0 ); @@ -444,14 +446,20 @@ public static ArrayList< Interval > distributeIntervalsFixedOverlap( final Inter public static long lastImageSize( final long l, final long s, final long o) { - return o + ( l - 2 * ( s-o ) - o ) % ( s - 2 * o + o ); - } + long size = o + ( l - 2 * ( s-o ) - o ) % ( s - 2 * o + o ); - public static double numCenterBlocks( final double l, final double s, final double o ) - { - return ( l - 2.0 * ( s-o ) - o ) / ( s - 2.0 * o + o ); + // this happens when it is only two overlapping images + if ( size < 0 ) + size = l + size; + + return size; } + //public static double numCenterBlocks( final double l, final double s, final double o ) + //{ + // return ( l - 2.0 * ( s-o ) - o ) / ( s - 2.0 * o + o ); + //} + public static ArrayList< Pair< Long, Long > > splitDim( final Interval input, final int d, @@ -482,11 +490,11 @@ public static ArrayList< Pair< Long, Long > > splitDim( public static void main( String[] args ) { - Interval input = new FinalInterval( new long[]{ 0 }, new long[] { 2048 - 1 } ); + Interval input = new FinalInterval( new long[]{ 0 }, new long[] { 14192 - 1 } ); - long[] overlapPx = new long[] { 17 }; - long[] targetSize = new long[] { 500 }; - long[] minStepSize = new long[] { 32 }; + long[] overlapPx = new long[] { 128 }; + long[] targetSize = new long[] { 6000 }; + long[] minStepSize = new long[] { 64 }; targetSize[ 0 ] = Split_Views.closestLongDivisableBy( targetSize[ 0 ], minStepSize[ 0 ] ); overlapPx[ 0 ] = Split_Views.closestLargerLongDivisableBy( overlapPx[ 0 ], minStepSize[ 0 ] );