/** * Minimize the displacement of all {@link PointMatch Correspondence pairs} * of all {@link Tile Tiles} and tell about it. * * @param maxAllowedError * @param maxIterations * @param maxPlateauwidth * @throws NotEnoughDataPointsException * @throws IllDefinedDataPointsException */ public void optimize( final double maxAllowedError, final int maxIterations, final int maxPlateauwidth ) throws NotEnoughDataPointsException, IllDefinedDataPointsException { optimize( maxAllowedError, maxIterations, maxPlateauwidth, 1.0f ); }
final TileConfiguration tc = new TileConfiguration(); if ( fixedViews.contains( viewId ) && !tc.getFixedTiles().contains( tile ) ) else IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Fixing view-tile [" + Group.pvid( viewId ) + "]" ); tc.fixTile( tile ); if ( tile.getConnectedTiles().size() > 0 || tc.getFixedTiles().contains( tile ) ) tc.addTile( tile );
@Override public boolean isConverged( TileConfiguration tc ) { double avgErr = tc.getError(); double maxErr = tc.getMaxError(); // the minMaxError makes sure that no links are dropped if the maximal error is already below a pixel if ( ( ( avgErr*relativeThreshold < maxErr && maxErr > minMaxError ) || avgErr > absoluteThreshold ) ) return false; else return true; } }
addPointMatches( pair.inliers, tiles.get( pair.indexA ), tiles.get( pair.indexB ) ); final TileConfiguration tc = new TileConfiguration(); tc.addTile( tile ); tc.fixTile( tile ); fixed = true; tc.preAlign( ); tc.optimize( 10, 10000, 200 ); IJ.log( "average displacement: " + tc.getError() + " px" ); IJ.log( "minimal displacement: " + tc.getMinError() + " px" ); IJ.log( "maximal displacement: " + tc.getMaxError() + " px" );
final TileConfiguration tc = new TileConfiguration(); if ( tile.getConnectedTiles().size() > 0 || tc.getFixedTiles().contains( tile ) ) tc.addTile( tile ); int unaligned = tc.preAlign().size(); if ( unaligned > 0 ) IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): pre-aligned all tiles but " + unaligned ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): prealigned all tiles" ); tc.optimize( 5, 300, 200 ); tc.getTiles().size() + " view-tiles:" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Avg Error: " + tc.getError() + "px" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Min Error: " + tc.getMinError() + "px" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Max Error: " + tc.getMaxError() + "px" );
if ( tc.getTiles().size() == 0 ) int unaligned = tc.preAlign().size(); if ( unaligned > 0 ) IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): pre-aligned all tiles but " + unaligned ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): prealigned all tiles" ); tc.optimize( cs.getMaxError(), cs.getMaxIterations(), cs.getMaxPlateauWidth() ); tc.getTiles().size() + " view-tiles (Model=" + model.getClass().getSimpleName() + "):" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Avg Error: " + tc.getError() + "px" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Min Error: " + tc.getMinError() + "px" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Max Error: " + tc.getMaxError() + "px" );
final TileConfiguration tc = new TileConfiguration(); for ( final ArrayList< Tile< ? extends M > > coefficients : coefficientsTiles.values() ) tc.addTiles( coefficients ); tc.optimize( 0.01f, iterations, iterations, 0.75f );
int unaligned = tc.preAlign().size(); if ( unaligned > 0 ) IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): pre-aligned all tiles but " + unaligned ); tc, tc.getTiles(), tc.getFixedTiles(), Runtime.getRuntime().availableProcessors()); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Global optimization of " + tc.getTiles().size()); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Avg Error: " + tc.getError() + "px" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Min Error: " + tc.getMinError() + "px" ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Max Error: " + tc.getMaxError() + "px" );
final static public class Param extends mpicbg.trakem2.align.AbstractLayerAlignmentParam implements Serializable { private static final long serialVersionUID = 208742614581106404L; public boolean isAligned = false; public double layerScale = 0.1; public float minR = 0.6f; public float maxCurvatureR = 10f; public float rodR = 0.9f; public int searchRadius = 200; public int blockRadius = -1; public boolean useLocalSmoothnessFilter = true; public int localModelIndex = 1; public float localRegionSigma = searchRadius; public float maxLocalEpsilon = searchRadius / 2; public float maxLocalTrust = 3; public int resolutionSpringMesh = 16; public double stiffnessSpringMesh = 0.1; public double dampSpringMesh = 0.9; public double maxStretchSpringMesh = 2000.0; public int maxIterationsSpringMesh = 1000; public int maxPlateauwidthSpringMesh = 200; public boolean useLegacyOptimizer = true; public boolean useTps = true; public boolean setup( final Rectangle box )
tc.apply(); tc.updateErrors(); observer.add( tc.getError() ); proceed = tc.getError() > maxAllowedError;
if ( getFixedTiles().size() == 0 ) final Iterator< Tile< ? > > it = this.getTiles().iterator(); alignedTiles.add( it.next() ); while ( it.hasNext() ) for ( final Tile< ? > tile : this.getTiles() ) if ( this.getFixedTiles().contains( tile ) ) alignedTiles.add( tile ); else final ArrayList< PointMatch > pm = getConnectingPointMatches( targetTile, referenceTile );
final static public class Param extends AbstractLayerAlignmentParam implements Serializable { /** * Regularization */ public boolean regularize = false; public int regularizerIndex = 1; public double lambda = 0.1; public boolean setup( final Rectangle box ) { if ( !setupSIFT( "Elastically align layers: " ) ) return false; /* Geometric filters */ final GenericDialog gd = new GenericDialog( "Align layers: Geometric filters" ); gd.addNumericField( "maximal_alignment_error :", maxEpsilon, 2, 6, "px" ); gd.addNumericField( "minimal_inlier_ratio :", minInlierRatio, 2 ); gd.addNumericField( "minimal_number_of_inliers :", minNumInliers, 0 ); gd.addChoice( "expected_transformation :", Param.modelStrings, Param.modelStrings[ expectedModelIndex ] ); gd.addCheckbox( "test_multiple_hypotheses", multipleHypotheses ); gd.addCheckbox( "widest_set_only", widestSetOnly ); gd.addCheckbox( "ignore constant background", rejectIdentity ); gd.addNumericField( "tolerance :", identityTolerance, 2, 6, "px" ); gd.addMessage( "Layer neighbor range:" ); gd.addNumericField( "test_maximally :", maxNumNeighbors, 0, 6, "layers" ); gd.addNumericField( "give_up_after :", maxNumFailures, 0, 6, "failures" );
final TileConfiguration initMeshes = new TileConfiguration(); initMeshes.addTiles( tiles ); initMeshes.optimize( p.maxEpsilon, p.maxIterationsSpringMesh, p.maxPlateauwidthSpringMesh ); for ( int i = 0; i < stack.getSize(); ++i ) meshes.get( i ).init( tiles.get( i ).getModel() );
tc.apply(); tc.updateErrors(); observer.add( tc.getError() ); proceed = tc.getError() > maxAllowedError;
if ( getFixedTiles().size() == 0 ) final Iterator< Tile< ? > > it = this.getTiles().iterator(); alignedTiles.add( it.next() ); while ( it.hasNext() ) for ( final Tile< ? > tile : this.getTiles() ) if ( this.getFixedTiles().contains( tile ) ) alignedTiles.add( tile ); else final ArrayList< PointMatch > pm = getConnectingPointMatches( targetTile, referenceTile );
final TileConfiguration initMeshes = new TileConfiguration(); initMeshes.addTiles( tiles ); initMeshes.optimize( p.maxEpsilon, p.maxIterationsSpringMesh, p.maxPlateauwidthSpringMesh ); for ( int i = 0; i < stack.getSize(); ++i ) meshes.get( i ).init( tiles.get( i ).getModel() );