/** * Call {@link #filterRansac(List, Collection, int, double, double, double)} * with maxTrust = 4. */ @Override final public < P extends PointMatch >boolean filterRansac( final List< P > candidates, final Collection< P > inliers, final int iterations, final double maxEpsilon, final double minInlierRatio ) throws NotEnoughDataPointsException { return filterRansac( candidates, inliers, iterations, maxEpsilon, minInlierRatio, 4f ); }
/** * Call {@link #filter(Collection, Collection, double)} with maxTrust = 4 and minNumInliers = {@link AbstractModel#getMinNumMatches()}. */ @Override final public < P extends PointMatch >boolean filter( final Collection< P > candidates, final Collection< P > inliers ) throws NotEnoughDataPointsException { return filter( candidates, inliers, 4f, getMinNumMatches() ); }
/** * Call {@link #test(Collection, Collection, double, double, int)} with * minNumInliers = {@link #getMinNumMatches()}. */ @Override final public < P extends PointMatch >boolean test( final Collection< P > candidates, final Collection< P > inliers, final double epsilon, final double minInlierRatio ) { return test( candidates, inliers, epsilon, minInlierRatio, getMinNumMatches() ); }
/** * Call {@link #ransac(List, Collection, int, double, double, int)} with * minNumInliers = {@link #getMinNumMatches()}. */ @Override final public < P extends PointMatch >boolean ransac( final List< P > candidates, final Collection< P > inliers, final int iterations, final double epsilon, final double minInlierRatio ) throws NotEnoughDataPointsException { return ransac( candidates, inliers, iterations, epsilon, minInlierRatio, getMinNumMatches() ); }
if ( candidates.size() < getMinNumMatches() ) throw new NotEnoughDataPointsException( candidates.size() + " data points are not enough to solve the Model, at least " + getMinNumMatches() + " data points required." ); final M copy = copy(); final M m = copy(); for ( int j = 0; j < getMinNumMatches(); ++j ) try { m.fit( minMatches ); } catch ( final IllDefinedDataPointsException e ) boolean isGood = m.test( candidates, tempInliers, epsilon, minInlierRatio ); while ( isGood && numInliers < tempInliers.size() ) try { m.fit( tempInliers ); } catch ( final IllDefinedDataPointsException e ) isGood = m.test( candidates, tempInliers, epsilon, minInlierRatio, minNumInliers ); m.betterThan( copy ) && tempInliers.size() >= minNumInliers ) copy.set( m ); inliers.clear(); inliers.addAll( tempInliers ); set( copy ); return true;
throws NotEnoughDataPointsException if ( candidates.size() < getMinNumMatches() ) throw new NotEnoughDataPointsException( candidates.size() + " data points are not enough to solve the Model, at least " + getMinNumMatches() + " data points required." ); final M copy = copy(); try copy.fit( inliers ); return false; set( copy ); return true;
localSmoothnessFilterModel.localSmoothnessFilter( pm12, pm12, p.localRegionSigma, p.maxLocalEpsilon, p.maxLocalTrust ); IJ.log( pair.a + " > " + pair.b + ": " + pm12.size() + " candidates passed local smoothness filter." ); localSmoothnessFilterModel.localSmoothnessFilter( pm21, pm21, p.localRegionSigma, p.maxLocalEpsilon, p.maxLocalTrust ); IJ.log( pair.a + " < " + pair.b + ": " + pm21.size() + " candidates passed local smoothness filter." ); final Tile< ? > t2 = tiles.get( pair.b ); if ( pm12.size() > pair.c.getMinNumMatches() ) t1.connect( t2, pm12 ); if ( pm21.size() > pair.c.getMinNumMatches() ) t2.connect( t1, pm21 );
fit( matches );
try modelFound = model.filterRansac( candidates, inliers, IJ.log( inliers.size() + " corresponding features with a maximal displacement of " + decimalFormat.format( model.getCost() ) + "px identified." ); IJ.log( "Estimated transformation model: " + model );
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 )
public void run() { final int myNumber = ai.getAndIncrement(); for ( int i = 0; i < pairs.size(); i++ ) if ( i%numThreads == myNumber ) { final ComparePair pair = pairs.get( i ); pair.model = pairwiseMatching( pair.inliers, peaks.get( pair.indexA ), peaks.get( pair.indexB ), zStretching, zStretching, params, pair.indexA + "<->" + pair.indexB ); if ( pair.model == null ) { pair.inliers.clear(); pair.model = params.model.copy(); } } } });
localSmoothnessFilterModel.localSmoothnessFilter( pm12, pm12, localRegionSigma, maxLocalEpsilon, param.maxLocalTrust ); localSmoothnessFilterModel.localSmoothnessFilter( pm21, pm21, localRegionSigma, maxLocalEpsilon, param.maxLocalTrust );
Utils.log( "Model found for tiles \"" + tilePair[ 0 ].getPatch() + "\" and \"" + tilePair[ 1 ].getPatch() + "\":\n correspondences " + inliers.size() + " of " + candidates.size() + "\n average residual error " + model.getCost() + " px\n took " + ( System.currentTimeMillis() - s ) + " ms" ); else Utils.log( "No model found for tiles \"" + tilePair[ 0 ].getPatch() + "\" and \"" + tilePair[ 1 ].getPatch() + "\":\n correspondence candidates " + candidates.size() + "\n took " + ( System.currentTimeMillis() - s ) + " ms" );
pb[ i ] = computedModel.apply( pa[ i ] );
if ( candidates.size() < getMinNumMatches() ) throw new NotEnoughDataPointsException( candidates.size() + " data points are not enough to solve the Model, at least " + getMinNumMatches() + " data points required." ); final M copy = copy(); final M m = copy(); for ( int j = 0; j < getMinNumMatches(); ++j ) try { m.fit( minMatches ); } catch ( final IllDefinedDataPointsException e ) boolean isGood = m.test( candidates, tempInliers, epsilon, minInlierRatio ); while ( isGood && numInliers < tempInliers.size() ) try { m.fit( tempInliers ); } catch ( final IllDefinedDataPointsException e ) isGood = m.test( candidates, tempInliers, epsilon, minInlierRatio, minNumInliers ); m.betterThan( copy ) && tempInliers.size() >= minNumInliers ) copy.set( m ); inliers.clear(); inliers.addAll( tempInliers ); set( copy ); return true;
throws NotEnoughDataPointsException if ( candidates.size() < getMinNumMatches() ) throw new NotEnoughDataPointsException( candidates.size() + " data points are not enough to solve the Model, at least " + getMinNumMatches() + " data points required." ); final M copy = copy(); try copy.fit( inliers ); return false; set( copy ); return true;
localSmoothnessFilterModel.localSmoothnessFilter( pm12, pm12, p.localRegionSigma, p.maxLocalEpsilon, p.maxLocalTrust ); IJ.log( pair.a + " > " + pair.b + ": " + pm12.size() + " candidates passed local smoothness filter." ); localSmoothnessFilterModel.localSmoothnessFilter( pm21, pm21, p.localRegionSigma, p.maxLocalEpsilon, p.maxLocalTrust ); IJ.log( pair.a + " < " + pair.b + ": " + pm21.size() + " candidates passed local smoothness filter." ); final Tile< ? > t2 = tiles.get( pair.b ); if ( pm12.size() > pair.c.getMinNumMatches() ) t1.connect( t2, pm12 ); if ( pm21.size() > pair.c.getMinNumMatches() ) t2.connect( t1, pm21 );
fit( matches );
try modelFound = model.filterRansac( candidates, inliers, IJ.log( inliers.size() + " corresponding features with a maximal displacement of " + decimalFormat.format( model.getCost() ) + "px identified." ); IJ.log( "Estimated transformation model: " + model );