From 3fd74b3941fd3ea5c613e72d379d059fe8cbcb28 Mon Sep 17 00:00:00 2001 From: John Bogovic Date: Tue, 12 Nov 2024 14:58:56 -0500 Subject: [PATCH] perf: do not fitBaselineWarpMagModel when not needed * i.e. when the warp magnitude source is not present * and minor clean up --- src/main/java/bigwarp/BigWarp.java | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/bigwarp/BigWarp.java b/src/main/java/bigwarp/BigWarp.java index ba00b5b..254f73e 100755 --- a/src/main/java/bigwarp/BigWarp.java +++ b/src/main/java/bigwarp/BigWarp.java @@ -2682,20 +2682,20 @@ public void setWarpMagBaselineIndex( int index ) protected void fitBaselineWarpMagModel() { - final int numActive = landmarkModel.numActive(); - if( numActive < 4 ) - return; + if( warpMagSource != null ) + { + final int numActive = landmarkModel.numActive(); + if( numActive < 4 ) + return; - final int ndims = landmarkModel.getNumdims(); - final double[][] p = new double[ ndims ][ numActive ]; - final double[][] q = new double[ ndims ][ numActive ]; - final double[] w = new double[ numActive ]; + final int ndims = landmarkModel.getNumdims(); + final double[][] p = new double[ ndims ][ numActive ]; + final double[][] q = new double[ ndims ][ numActive ]; + final double[] w = new double[ numActive ]; - landmarkModel.copyLandmarks( p, q ); - Arrays.fill( w, 1.0 ); + landmarkModel.copyLandmarks( p, q ); + Arrays.fill( w, 1.0 ); - if( warpMagSource != null ) - { try { final AbstractModel< ? > baseline = this.baseXfmList[ baselineModelIndex ]; @@ -3032,10 +3032,9 @@ private void setTransformationAll( final InvertibleRealTransform transform ) public boolean restimateTransformation() { - if ( landmarkModel.getActiveRowCount() < 4 ) - { + if (landmarkModel.getActiveRowCount() < 4) return false; - } + // TODO restimateTransformation // This distinction is unnecessary right now, because // transferUpdatesToModel just calls initTransformation.. but this may