throw new NotEnoughDataPointsException( l + " data points are not enough to estimate a 1d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
@Override final public <P extends PointMatch> void fit( final Collection< P > matches ) throws NotEnoughDataPointsException, IllDefinedDataPointsException { if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " matches given, we need at least " + MIN_NUM_MATCHES + " data point." ); }
throw new NotEnoughDataPointsException( l + " data points are not enough to estimate a 1d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
throw new NotEnoughDataPointsException( l + " data points are not enough to estimate a 1d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
@Override final public <P extends PointMatch> void fit( final Collection< P > matches ) throws NotEnoughDataPointsException, IllDefinedDataPointsException { if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " matches given, we need at least " + MIN_NUM_MATCHES + " data point." ); }
throw new NotEnoughDataPointsException( l + " data points are not enough to estimate a 1d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
throw new NotEnoughDataPointsException( l + " data points are not enough to estimate a 2d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
throw new NotEnoughDataPointsException( l + " data points are not enough to estimate a 2d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
throw new NotEnoughDataPointsException( l + " data points are not enough to estimate a 2d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
@Override final public < P extends PointMatch >void fit( final Collection< P > matches ) throws NotEnoughDataPointsException { if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 1d translation model, at least " + MIN_NUM_MATCHES + " data points required." ); // center of mass: double pcx = 0; double qcx = 0; double ws = 0.0f; for ( final P m : matches ) { final double[] p = m.getP1().getL(); final double[] q = m.getP2().getW(); final double w = m.getWeight(); ws += w; pcx += w * p[ 0 ]; qcx += w * q[ 0 ]; } pcx /= ws; qcx /= ws; t = qcx - pcx; }
@Override final public < P extends PointMatch >void fit( final Collection< P > matches ) throws NotEnoughDataPointsException { if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 1d translation model, at least " + MIN_NUM_MATCHES + " data points required." ); // center of mass: double pcx = 0; double qcx = 0; double ws = 0.0f; for ( final P m : matches ) { final double[] p = m.getP1().getL(); final double[] q = m.getP2().getW(); final double w = m.getWeight(); ws += w; pcx += w * p[ 0 ]; qcx += w * q[ 0 ]; } pcx /= ws; qcx /= ws; t = qcx - pcx; }
/** * Closed form weighted least squares solution as described by * \citet{SchaeferAl06} and implemented by Johannes Schindelin. */ @Override final public < P extends PointMatch >void fit( final Collection< P > matches ) throws NotEnoughDataPointsException { if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 2d rigid model, at least " + MIN_NUM_MATCHES + " data points required." ); cos = 0; sin = 0; for ( final P m : matches ) { final double[] p = m.getP1().getL(); final double[] q = m.getP2().getW(); final double w = m.getWeight(); final double x1 = p[ 0 ]; final double y1 = p[ 1 ]; // x2 final double x2 = q[ 0 ]; // y1 final double y2 = q[ 1 ]; // y2 sin += w * ( x1 * y2 - y1 * x2 ); // x1 * y2 - x2 * y1 // assuming p1 is x1,x2 and p2 is y1,y2 cos += w * ( x1 * x2 + y1 * y2 ); // x1 * y1 + x2 * y2 } final double norm = Math.sqrt( cos * cos + sin * sin ); cos /= norm; sin /= norm; } }
@Override final public < P extends PointMatch >void fit( final Collection< P > matches ) throws NotEnoughDataPointsException { if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 2d translation model, at least " + MIN_NUM_MATCHES + " data points required." ); // center of mass: double pcx = 0, pcy = 0; double qcx = 0, qcy = 0; double ws = 0.0f; for ( final P m : matches ) { final double[] p = m.getP1().getL(); final double[] q = m.getP2().getW(); final double w = m.getWeight(); ws += w; pcx += w * p[ 0 ]; pcy += w * p[ 1 ]; qcx += w * q[ 0 ]; qcy += w * q[ 1 ]; } pcx /= ws; pcy /= ws; qcx /= ws; qcy /= ws; tx = qcx - pcx; ty = qcy - pcy; }
model.fit( p, q, w ); else throw new NotEnoughDataPointsException( "No matches passed." );
@Override final public < P extends PointMatch >void fit( final Collection< P > matches ) throws NotEnoughDataPointsException { if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 2d translation model, at least " + MIN_NUM_MATCHES + " data points required." ); // center of mass: double pcx = 0, pcy = 0; double qcx = 0, qcy = 0; double ws = 0.0f; for ( final P m : matches ) { final double[] p = m.getP1().getL(); final double[] q = m.getP2().getW(); final double w = m.getWeight(); ws += w; pcx += w * p[ 0 ]; pcy += w * p[ 1 ]; qcx += w * q[ 0 ]; qcy += w * q[ 1 ]; } pcx /= ws; pcy /= ws; qcx /= ws; qcy /= ws; tx = qcx - pcx; ty = qcy - pcy; }
model.fit( p, q, w ); else throw new NotEnoughDataPointsException( "No matches passed." );
@Override final public < P extends PointMatch >void fit( final Collection< P > matches ) throws NotEnoughDataPointsException if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 3d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
@Override final public < P extends PointMatch >void fit( final Collection< P > matches ) throws NotEnoughDataPointsException if ( matches.size() < MIN_NUM_MATCHES ) throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 3d translation model, at least " + MIN_NUM_MATCHES + " data points required." );
@Override public < P extends PointMatch >void fit( final Collection< P > pointMatches ) throws NotEnoughDataPointsException, IllDefinedDataPointsException { if ( pointMatches.size() < getMinNumMatches() ) throw new NotEnoughDataPointsException( pointMatches.size() + " data points are not enough to estimate a 2d polynomial of order " + nlt.getDimension() + ", at least " + getMinNumMatches() + " data points required." ); affine.fit( pointMatches ); final double h1[][] = new double[ pointMatches.size() ][ 2 ]; final double h2[][] = new double[ pointMatches.size() ][ 2 ]; int i = 0; for ( final P match : pointMatches ) { final double[] tmp1 = match.getP1().getL().clone(); affine.applyInPlace( tmp1 ); final double[] tmp2 = match.getP2().getW(); h1[ i ] = new double[]{ tmp1[ 0 ], tmp1[ 1 ] }; h2[ i ] = new double[]{ tmp2[ 0 ], tmp2[ 1 ] }; ++i; } nlt.fit( h1, h2, lambda ); }
throw new NotEnoughDataPointsException( matches.size() + " data points are not enough to estimate a 2d affine model, at least " + MIN_NUM_MATCHES + " data points required." );