@Override public void applyInPlace( final double[] location ) { final float[] ww = new float[ w.length ]; for ( int i = 0; i < w.length; ++i ) { double s = 0; for ( int d = 0; d < location.length; ++d ) { final double dx = p[ d ][ i ] - location[ d ]; s += dx * dx; } if ( s <= 0 ) { for ( int d = 0; d < location.length; ++d ) location[ d ] = q[ d ][ i ]; return; } ww[ i ] = ( float )( w[ i ] * weigh( s ) ); } try { model.fit( p, q, ww ); model.applyInPlace( location ); } catch ( final IllDefinedDataPointsException e ){} catch ( final NotEnoughDataPointsException e ){} } }
public ComparePair( final int indexA, final int indexB, final Model<?> model ) { this.indexA = indexA; this.indexB = indexB; this.model = model.copy(); }
@Override public void filter( List< PointMatch > candidates, Collection< PointMatch > inliers ) { try { if ( !model.filterRansac( candidates, inliers, iterations, maxEpsilon, minInlierRatio, minNumInliers, maxTrust ) ) inliers.clear(); } catch ( Exception e ) { inliers.clear(); } }
@Override public void applyInPlace( final double[] location ) { final double[] copy = b.apply( location ); a.applyInPlace( location ); for ( int d = 0; d < location.length; ++d ) { final double dd = copy[ d ] - location[ d ]; location[ d ] += lambda * dd; } } }
/** * Update the transformation {@link AbstractModel}. That is, fit it to the * current set of {@link PointMatch PointMatches}. */ final public void fitModel() throws NotEnoughDataPointsException, IllDefinedDataPointsException { model.fit( matches ); }
modelFound = model.filterRansac( candidates, inliers, modelFound = model.ransac( candidates, inliers, if ( modelFound && inliers.size() > model.getMinNumMatches() * minInlierFactor ) model.fit( inliers ); return "Remaining inliers after RANSAC (" + model.getClass().getSimpleName() + "): " + inliers.size() + " of " + candidates.size() + " with average error " + model.getCost();
if ( pm.size() >= targetTile.getModel().getMinNumMatches() ) targetTile.getModel().fit( pm );
final static protected class MatchFeaturesAndFindModelThread extends Thread { final protected Param p; final protected List< AbstractAffineTile2D< ? > > tiles; //final protected HashMap< AbstractAffineTile2D< ? >, Collection< Feature > > tileFeatures; final protected List< AbstractAffineTile2D< ? >[] > tilePairs; final protected AtomicInteger ai; final protected AtomicInteger ap; final protected int steps; final protected boolean multipleHypotheses; public MatchFeaturesAndFindModelThread( final Param p, final List< AbstractAffineTile2D< ? > > tiles, final List< AbstractAffineTile2D< ? >[] > tilePairs, final AtomicInteger ai, final AtomicInteger ap, final int steps, final boolean multipleHypotheses ) { this.p = p; this.tiles = tiles; this.tilePairs = tilePairs; this.ai = ai; this.ap = ap; this.steps = steps; this.multipleHypotheses = multipleHypotheses; } public MatchFeaturesAndFindModelThread(
model.filterRansac( candidates, inliers, maxTrust ) ) model.fit( inliers );
@Override public void applyInPlace( final double[] location ) { model.applyInPlace( location ); } }
final int minNumCorrespondences = Math.max( model.getMinNumMatches(), (int)Math.round( model.getMinNumMatches() * minNumberInlierFactor ) ); modelFound = model.filterRansac( candidates, inliers, return new ValuePair< String, Double >( "Remaining inliers after RANSAC: " + inliers.size() + " of " + candidates.size() + " (" + nf.format(ratio) + ") with average error " + model.getCost(), model.getCost() );
@Override public int getMinNumMatches() { return Math.max( a.getMinNumMatches(), b.getMinNumMatches() ); }
/** * Update {@link #cost} and {@link #distance}. */ final public void updateCost() { double d = 0.0; double c = 0.0; final int numMatches = matches.size(); if ( numMatches > 0 ) { double sumWeight = 0.0; for ( final PointMatch match : matches ) { final double dl = match.getDistance(); d += dl; c += dl * dl * match.getWeight(); sumWeight += match.getWeight(); } d /= numMatches; c /= sumWeight; } distance = d; cost = c; model.setCost( c ); }
if ( pm.size() >= targetTile.getModel().getMinNumMatches() ) targetTile.getModel().fit( pm );
featuresModel.filterRansac( candidates, inliers, case Register_Virtual_Stack_MT.RIGID: case Register_Virtual_Stack_MT.AFFINE: ((Model<?>)t).fit(inliers); break; case Register_Virtual_Stack_MT.ELASTIC:
@Override public void applyInverseInPlace( final double[] location ) throws NoninvertibleModelException { model.applyInPlace( location ); }
@Override public void applyInPlace( final double[] location ) { final double[] copy = b.apply( location ); a.applyInPlace( location ); for ( int d = 0; d < location.length; ++d ) { final double dd = copy[ d ] - location[ d ]; location[ d ] += lambda * dd; } } }
@Override public int getMinNumMatches() { return Math.max( a.getMinNumMatches(), b.getMinNumMatches() ); }
/** * Update {@link #cost} and {@link #distance}. */ final public void updateCost() { double d = 0.0; double c = 0.0; final int numMatches = matches.size(); if ( numMatches > 0 ) { double sumWeight = 0.0; for ( final PointMatch match : matches ) { final double dl = match.getDistance(); d += dl; c += dl * dl * match.getWeight(); sumWeight += match.getWeight(); } d /= numMatches; c /= sumWeight; } distance = d; cost = c; model.setCost( c ); }