Skip to content

Commit

Permalink
perf: do not fitBaselineWarpMagModel when not needed
Browse files Browse the repository at this point in the history
* i.e. when the warp magnitude source is not present
* and minor clean up
  • Loading branch information
bogovicj committed Nov 12, 2024
1 parent 0b3ea96 commit 3fd74b3
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/main/java/bigwarp/BigWarp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3fd74b3

Please sign in to comment.