Skip to content

Commit

Permalink
Merge pull request #52 from PreibischLab/stepsize
Browse files Browse the repository at this point in the history
Simplify DownSampleTools.getStepSize() and use double precision
  • Loading branch information
StephanPreibisch authored Mar 5, 2024
2 parents f2a7107 + b5f66c6 commit 06b61cc
Showing 1 changed file with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import mpicbg.spim.data.sequence.VoxelDimensions;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.util.LinAlgHelpers;
import net.imglib2.type.numeric.real.FloatType;
import net.imglib2.util.Pair;
import net.imglib2.util.Util;
Expand Down Expand Up @@ -108,7 +109,7 @@ public static Pair< RandomAccessibleInterval, AffineTransform3D > openDownsample
final double[][] mipmapResolutions = mrImgLoader.getSetupImgLoader( viewId.getViewSetupId() ).getMipmapResolutions();

// best possible step size in the output image when using original data
final float[] sizeMaxResolution = getStepSize( m );
final double[] sizeMaxResolution = getStepSize( m );

//System.out.println( Util.printCoordinates( sizeMaxResolution ) );
float acceptedError = 0.02f;
Expand All @@ -133,7 +134,7 @@ public static Pair< RandomAccessibleInterval, AffineTransform3D > openDownsample
AffineTransform3D model = m.copy();
model.concatenate( s );

final float[] size = getStepSize( model );
final double[] size = getStepSize( model );

boolean isValid = true;

Expand Down Expand Up @@ -186,29 +187,16 @@ public static Pair< RandomAccessibleInterval, AffineTransform3D > openDownsample
}
}

private static float[] getStepSize( final AffineTransform3D model )
private static double[] getStepSize( final AffineTransform3D model )
{
final float[] size = new float[ 3 ];

final double[] size = new double[ 3 ];
final double[] tmp = new double[ 3 ];
final double[] o0 = new double[ 3 ];

model.apply( tmp, o0 );

for ( int d = 0; d < 3; ++d )
{
final double[] o1 = new double[ 3 ];

for ( int i = 0; i < tmp.length; ++i )
tmp[ i ] = 0;

tmp[ d ] = 1;

model.apply( tmp, o1 );

size[ d ] = (float)length( o1, o0 );
for ( int i = 0; i < 3; ++i )
tmp[ i ] = model.get( i, d );
size[ d ] = LinAlgHelpers.length( tmp );
}

return size;
}

Expand Down

0 comments on commit 06b61cc

Please sign in to comment.