本文整理汇总了Java中mpicbg.models.NotEnoughDataPointsException类的典型用法代码示例。如果您正苦于以下问题:Java NotEnoughDataPointsException类的具体用法?Java NotEnoughDataPointsException怎么用?Java NotEnoughDataPointsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotEnoughDataPointsException类属于mpicbg.models包,在下文中一共展示了NotEnoughDataPointsException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sampleAverageScale
点赞 3
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
/**
* Sample the average scaling of a given {@link CoordinateTransform} by transferring a set of point samples using
* the {@link CoordinateTransform} and then least-squares fitting a {@link SimilarityModel2D} to it.
*
* @param width of the samples set
* @param height of the samples set
* @param dx spacing between samples
*
* @return average scale factor
*/
public static double sampleAverageScale(final CoordinateTransform ct,
final int width,
final int height,
final double dx) {
final ArrayList<PointMatch> samples = new ArrayList<>();
for (double y = 0; y < height; y += dx) {
for (double x = 0; x < width; x += dx) {
final Point p = new Point(new double[]{x, y});
p.apply(ct);
samples.add(new PointMatch(p, p));
}
}
final AffineModel2D model = new AffineModel2D();
try {
model.fit(samples);
} catch (final NotEnoughDataPointsException | IllDefinedDataPointsException e) {
LOG.warn("failed to fit samples, returning scale factor of 1", e);
return 1;
}
final double[] data = new double[6];
model.toArray(data);
// return 1;
return Math.sqrt(Math.max(data[0] * data[0] + data[1] * data[1], data[2] * data[2] + data[3] * data[3]));
}
开发者ID:saalfeldlab,
项目名称:render,
代码行数:35,
代码来源:Utils.java
示例2: testRANSACFilterWithMinValue
点赞 3
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
private void testRANSACFilterWithMinValue(final List<PointMatch> candidates,
final int minNumInliers,
final int expectedInliersSizeAfterFilter)
throws NotEnoughDataPointsException {
final List<PointMatch> inliers = new ArrayList<>();
final int iterations = 1000;
final float maxEpsilon = 20f;
final float minInlierRatio = 0.0f;
final float maxTrust = 3.0f;
final AffineModel2D model = new AffineModel2D();
model.filterRansac(candidates,
inliers,
iterations,
maxEpsilon,
minInlierRatio,
minNumInliers,
maxTrust);
Assert.assertEquals("invalid number of inliers found with min " + minNumInliers,
expectedInliersSizeAfterFilter, inliers.size());
}
开发者ID:saalfeldlab,
项目名称:render,
代码行数:26,
代码来源:CanvasFeatureMatcherTest.java
示例3: estimateIntialModel
点赞 3
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
/**
* Estimates an initial {@link Model} based on some given {@link PointMatch}es. Note that the {@link PointMatch}es have to be stored as PointMatch(target,reference).
*
* @param matches - The {@link List} of apriori known {@link PointMatch}es
* @param model - The {@link Model} to use
* @throws NotEnoughDataPointsException
* @throws IllDefinedDataPointsException
*/
public void estimateIntialModel( final List<PointMatch> matches, final Model<?> model ) throws NotEnoughDataPointsException, IllDefinedDataPointsException
{
/* remove ambigous correspondences */
ambigousMatches = removeAmbigousMatches( matches );
/* fit the model */
model.fit( matches );
/* apply the new model of the target to determine the error */
for ( final P point : target )
point.apply( model );
/* compute the output */
avgError = PointMatch.meanDistance( matches );
maxError = PointMatch.maxDistance( matches );
numMatches = matches.size();
pointMatches = matches;
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:27,
代码来源:ICP.java
示例4: fit
点赞 3
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:30,
代码来源:TranslationInvariantRigidModel2D.java
示例5: fit
点赞 3
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
@Override
public < P extends PointMatch >void fit(final Collection< P > matches)
throws NotEnoughDataPointsException, IllDefinedDataPointsException
{
final Stack< java.awt.Point > sourcePoints = new Stack<java.awt.Point>();
final Stack< java.awt.Point > targetPoints = new Stack<java.awt.Point>();
for ( final P pm : matches )
{
final double[] p1 = pm.getP1().getL();
final double[] p2 = pm.getP2().getL();
targetPoints.add( new java.awt.Point( ( int )Math.round( p1[ 0 ] ), ( int )Math.round( p1[ 1 ] ) ) );
sourcePoints.add( new java.awt.Point( ( int )Math.round( p2[ 0 ] ), ( int )Math.round( p2[ 1 ] ) ) );
}
final Transformation transf = bUnwarpJ_.computeTransformationBatch(sourceWidth,
sourceHeight, width, height, sourcePoints, targetPoints, parameter);
this.set(transf.getIntervals(), transf.getDirectDeformationCoefficientsX(),
transf.getDirectDeformationCoefficientsY(), width, height);
}
开发者ID:trakem2,
项目名称:TrakEM2,
代码行数:23,
代码来源:CubicBSplineTransform.java
示例6: regularize
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
@Override
public void regularize( final double[] coordinates, final Options options ) throws NotEnoughDataPointsException, IllDefinedDataPointsException
{
final double[] relevantCoordinates = extractRelevantCoordinates( coordinates );
m.fit( new double[][] { relevantCoordinates }, new double[][] { regularizationValues }, weights );
for ( int i = 0; i < coordinates.length; ++i )
{
dummy[ 0 ] = coordinates[ i ];
m.applyInPlace( dummy );
coordinates[ i ] = dummy[ 0 ];
}
}
开发者ID:saalfeldlab,
项目名称:z-spacing,
代码行数:14,
代码来源:InferFromMatrix.java
示例7: filterMatches
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
public List<PointMatch> filterMatches(final List<PointMatch> candidates,
final Model model) {
final ArrayList<PointMatch> inliers = new ArrayList<>(candidates.size());
if (candidates.size() > 0) {
try {
model.filterRansac(candidates,
inliers,
iterations,
maxEpsilon,
minInlierRatio,
minNumInliers,
maxTrust);
} catch (final NotEnoughDataPointsException e) {
LOG.warn("failed to filter outliers", e);
}
// TODO: remove this extra check once RANSAC filter issue is fixed
if ((inliers.size() > 0) && (inliers.size() < minNumInliers)) {
LOG.warn("removing {} inliers that mysteriously did not get removed with minNumInliers value of {}",
inliers.size(), minNumInliers);
inliers.clear();
}
if ((maxNumInliers != null) && (maxNumInliers > 0) && (inliers.size() > maxNumInliers)) {
LOG.info("filterMatches: randomly selecting {} of {} inliers", maxNumInliers, inliers.size());
// randomly select maxNumInliers elements by shuffling and then remove excess elements
Collections.shuffle(inliers);
inliers.subList(maxNumInliers, inliers.size()).clear();
}
}
LOG.info("filterMatches: filtered {} inliers from {} candidates", inliers.size(), candidates.size());
return inliers;
}
开发者ID:saalfeldlab,
项目名称:render,
代码行数:39,
代码来源:CanvasFeatureMatcher.java
示例8: fit
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
@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." );
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:8,
代码来源:FixedModel.java
示例9: sampleAverageScale
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
/**
* Sample the average scaling of a given {@link CoordinateTransform} by transferring
* a set of point samples using the {@link CoordinateTransform} and then
* least-squares fitting a {@link SimilarityModel2D} to it.
*
* @param ct
* @param width of the samples set
* @param height of the samples set
* @param dx spacing between samples
*
* @return average scale factor
*/
final static protected double sampleAverageScale( final CoordinateTransform ct, final int width, final int height, final double dx )
{
final ArrayList< PointMatch > samples = new ArrayList< PointMatch >();
for ( double y = 0; y < height; y += dx )
{
for ( double x = 0; x < width; x += dx )
{
final Point p = new Point( new double[]{ x, y } );
p.apply( ct );
samples.add( new PointMatch( p, p ) );
}
}
final SimilarityModel2D model = new SimilarityModel2D();
try
{
model.fit( samples );
}
catch ( final NotEnoughDataPointsException e )
{
e.printStackTrace( System.err );
return 1;
}
final double[] data = new double[ 6 ];
model.toArray( data );
return Math.sqrt( data[ 0 ] * data[ 0 ] + data[ 1 ] * data[ 1 ] );
}
开发者ID:trakem2,
项目名称:TrakEM2,
代码行数:39,
代码来源:Render.java
示例10: fit
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
@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 );
}
开发者ID:trakem2,
项目名称:TrakEM2,
代码行数:28,
代码来源:PolynomialModel2D.java
示例11: getMediatedShifts
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
public < T extends RealType< T >, W extends RealType< W > > double[] getMediatedShifts(
final RandomAccessibleInterval< T > matrix,
final RandomAccessibleInterval< T > scaledMatrix,
final double[] lut,
final double[] scalingFactors,
final int iteration,
final RandomAccessibleInterval< double[] >[] correlationFitsStore,
final double[] shiftsArray,
final double[] weightSums,
final RandomAccessibleInterval< W > estimateWeightMatrix,
final double[] shiftWeights,
final Options options ) throws NotEnoughDataPointsException, IllDefinedDataPointsException
{
final int nMatrixDimensions = scaledMatrix.numDimensions();
final LUTRealTransform transform = new LUTRealTransform( lut, nMatrixDimensions, nMatrixDimensions );
// use scaled matrix
// TODO about 1/4 of runtime happens here
final RandomAccessibleInterval< double[] > fits =
correlationFit.estimateFromMatrix( scaledMatrix, lut, transform, estimateWeightMatrix, options );
correlationFitsStore[ 0 ] = fits;
// use original matrix to estimate scaling factors
// TODO more than half of runtime happens here -- only option to keep number of iterations low?
EstimateScalingFactors.estimateQuadraticFromMatrix( matrix,
scalingFactors,
lut,
fits,
options.scalingFactorRegularizerWeight,
options.comparisonRange,
options.scalingFactorEstimationIterations,
estimateWeightMatrix );
// write scaled matrix to scaledMatrix
final RandomAccess< T > matrixRA = matrix.randomAccess();
final RandomAccess< T > scaledMatrixRA = scaledMatrix.randomAccess();
for ( int z = 0; z < lut.length; ++z )
{
matrixRA.setPosition( z, 0 );
scaledMatrixRA.setPosition( z, 0 );
final int max = Math.min( lut.length, z + options.comparisonRange + 1 );
for ( int k = Math.max( 0, z - options.comparisonRange ); k < max; ++k )
{
matrixRA.setPosition( k, 1 );
scaledMatrixRA.setPosition( k, 1 );
scaledMatrixRA.get().set( matrixRA.get() );
if ( k != z )
scaledMatrixRA.get().mul( scalingFactors[ z ] * scalingFactors[ k ] );
}
}
// use scaled matrix to collect shifts
ShiftCoordinates.collectShiftsFromMatrix(
lut,
scaledMatrix,
scalingFactors,
fits,
shiftsArray,
weightSums,
shiftWeights,
options );
final double[] mediatedShifts = new double[ lut.length ];
mediateShifts( shiftsArray, weightSums, mediatedShifts );
return mediatedShifts;
}
开发者ID:saalfeldlab,
项目名称:z-spacing,
代码行数:69,
代码来源:InferFromMatrix.java
示例12: optimize
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
/**
* Minimize the displacement of all {@link PointMatch Correspondence pairs}
* of all {@link Tile Tiles}
*
* @param maxAllowedError do not accept convergence if error is < max_error
* @param maxIterations stop after that many iterations even if there was
* no minimum found
* @param maxPlateauwidth convergence is reached if the average absolute
* slope in an interval of this size and half this size is smaller than
* 0.0001 (in double accuracy). This is assumed to prevent the algorithm
* from stopping at plateaus smaller than this value.
* @param debugLevel defines if the Optimizer prints the output at the end of the process
*/
public void optimize(
final double maxAllowedError,
final int maxIterations,
final int maxPlateauwidth,
final int debugLevel ) throws NotEnoughDataPointsException, IllDefinedDataPointsException
{
final ErrorStatistic observer = new ErrorStatistic( maxPlateauwidth + 1 );
int i = 0;
boolean proceed = i < maxIterations;
while ( proceed )
{
for ( final TileSPIM tile : tiles )
{
if ( fixedTiles.contains( tile ) ) continue;
tile.update();
tile.fitModel();
tile.update();
}
update();
observer.add( error );
if ( i > maxPlateauwidth )
{
proceed = error > maxAllowedError;
int d = maxPlateauwidth;
while ( !proceed && d >= 1 )
{
try
{
proceed |= Math.abs( observer.getWideSlope( d ) ) > 0.0001;
}
catch ( Exception e ) { e.printStackTrace(); }
d /= 2;
}
}
proceed &= ++i < maxIterations;
}
if ( debugLevel <= ViewStructure.DEBUG_MAIN )
{
println( "Successfully optimized configuration of " + tiles.size() + " tiles after " + i + " iterations:" );
println( " average displacement: " + decimalFormat.format( error ) + "px" );
println( " minimal displacement: " + decimalFormat.format( minError ) + "px" );
println( " maximal displacement: " + decimalFormat.format( maxError ) + "px" );
}
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:65,
代码来源:TileConfigurationSPIM.java
示例13: fit
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
@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() + " data points are not enough to estimate a 3d affine model, at least " + MIN_NUM_MATCHES + " data points required." );
double
a00, a01, a02,
a11, a12,
a22;
double
b00, b01, b02,
b10, b11, b12,
b20, b21, b22;
a00 = a01 = a02 = a11 = a12 = a22 = b00 = b01 = b02 = b10 = b11 = b12 = b20 = b21 = b22 = 0;
for ( final PointMatch m : matches )
{
final double[] p = m.getP1().getL();
final double[] q = m.getP2().getW();
final double w = m.getWeight();
final double px = p[ 0 ], py = p[ 1 ], pz = p[ 2 ];
final double qx = q[ 0 ], qy = q[ 1 ], qz = q[ 2 ];
a00 += w * px * px;
a01 += w * px * py;
a02 += w * px * pz;
a11 += w * py * py;
a12 += w * py * pz;
a22 += w * pz * pz;
b00 += w * px * qx;
b01 += w * px * qy;
b02 += w * px * qz;
b10 += w * py * qx;
b11 += w * py * qy;
b12 += w * py * qz;
b20 += w * pz * qx;
b21 += w * pz * qy;
b22 += w * pz * qz;
}
final double det =
a00 * a11 * a22 +
a01 * a12 * a02 +
a02 * a01 * a12 -
a02 * a11 * a02 -
a12 * a12 * a00 -
a22 * a01 * a01;
if ( det == 0 )
throw new IllDefinedDataPointsException();
final double idet = 1f / det;
final double ai00 = ( a11 * a22 - a12 * a12 ) * idet;
final double ai01 = ( a02 * a12 - a01 * a22 ) * idet;
final double ai02 = ( a01 * a12 - a02 * a11 ) * idet;
final double ai11 = ( a00 * a22 - a02 * a02 ) * idet;
final double ai12 = ( a02 * a01 - a00 * a12 ) * idet;
final double ai22 = ( a00 * a11 - a01 * a01 ) * idet;
m00 = ai00 * b00 + ai01 * b10 + ai02 * b20;
m01 = ai01 * b00 + ai11 * b10 + ai12 * b20;
m02 = ai02 * b00 + ai12 * b10 + ai22 * b20;
m10 = ai00 * b01 + ai01 * b11 + ai02 * b21;
m11 = ai01 * b01 + ai11 * b11 + ai12 * b21;
m12 = ai02 * b01 + ai12 * b11 + ai22 * b21;
m20 = ai00 * b02 + ai01 * b12 + ai02 * b22;
m21 = ai01 * b02 + ai11 * b12 + ai12 * b22;
m22 = ai02 * b02 + ai12 * b12 + ai22 * b22;
}
开发者ID:fiji,
项目名称:SPIM_Registration,
代码行数:76,
代码来源:TranslationInvariantAffineModel3D.java
示例14: match
点赞 2
import mpicbg.models.NotEnoughDataPointsException; //导入依赖的package包/类
final static private int match(
final Param param,
final List< PointMatch > candidates,
final List< PointMatch > inliers,
final Model< ? > model )
{
boolean again = false;
int nHypotheses = 0;
double maxWidth = 0;
try
{
do
{
again = false;
final ArrayList< PointMatch > inliers2 = new ArrayList< PointMatch >();
final boolean modelFound = model.filterRansac(
candidates,
inliers2,
1000,
param.maxEpsilon,
param.minInlierRatio,
param.minNumInliers,
3 );
if ( modelFound )
{
candidates.removeAll( inliers2 );
if ( param.rejectIdentity )
{
final ArrayList< Point > points = new ArrayList< Point >();
PointMatch.sourcePoints( inliers2, points );
if ( Transforms.isIdentity( model, points, param.identityTolerance ) )
{
IJ.log( "Identity transform for " + inliers2.size() + " matches rejected." );
again = true;
continue;
}
}
++nHypotheses;
if ( param.widestSetOnly )
{
final double width = squareP1LocalWidth( inliers2 );
if ( width > maxWidth )
{
maxWidth = width;
inliers.clear();
inliers.addAll( inliers2 );
}
}
else
inliers.addAll( inliers2 );
again = param.multipleHypotheses | param.widestSetOnly;
}
}
while ( again );
}
catch ( final NotEnoughDataPointsException e ) {}
return nHypotheses;
}
开发者ID:trakem2,
项目名称:TrakEM2,
代码行数:63,
代码来源:RegularizedAffineLayerAlignment.java