mpicbg.models.Model Java Examples

The following examples show how to use mpicbg.models.Model. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Align.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
final static public boolean findModel(
		final Model< ? > model,
		final List< PointMatch > candidates,
		final Collection< PointMatch > inliers,
		final float maxEpsilon,
		final float minInlierRatio,
		final int minNumInliers,
		final boolean rejectIdentity,
		final float identityTolerance )
{
	return findModel(
			model,
			candidates,
			inliers,
			maxEpsilon,
			minInlierRatio,
			minNumInliers,
			rejectIdentity,
			identityTolerance,
			false );
}
 
Example #2
Source File: MatchIntensities.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
final static protected < T extends Model< T > & Affine1D< T > > HashMap< Patch, ArrayList< Tile< T > > > generateCoefficientsTiles(
		final Collection< Patch > patches,
		final T template,
		final int nCoefficients )
{
	final HashMap< Patch, ArrayList< Tile< T > > > map = new HashMap< Patch, ArrayList< Tile< T > > >();
	for ( final Patch p : patches )
	{
		final ArrayList< Tile< T > > coefficientModels = new ArrayList< Tile< T > >();
		for ( int i = 0; i < nCoefficients; ++i )
			coefficientModels.add( new Tile< T >( template.copy() ) );

		map.put( p, coefficientModels );
	}
	return map;
}
 
Example #3
Source File: ICP.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;		
}
 
Example #4
Source File: CanvasFeatureMatcher.java    From render with GNU General Public License v2.0 6 votes vote down vote up
public List<PointMatch> filterMatches(final List<PointMatch> candidates,
                                      final Model model) {

    final List<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);
        }

        postProcessInliers(inliers);

    }

    LOG.info("filterMatches: filtered {} inliers from {} candidates", inliers.size(), candidates.size());

    return inliers;
}
 
Example #5
Source File: CanvasFeatureMatchResult.java    From render with GNU General Public License v2.0 6 votes vote down vote up
PointMatchQualityStats calculateQualityStats()
        throws IllegalArgumentException {

    final PointMatchQualityStats qualityStats = new PointMatchQualityStats();

    final Model aggregateModel;
    if (AGGREGATED_CONSENSUS_SETS.equals(matcher.getFilterType()) || (consensusSetInliers.size() > 1)) {
        aggregateModel = matcher.getModel();
    } else {
        aggregateModel = null;
    }

    try {
        qualityStats.calculate(consensusSetInliers, aggregateModel);
    } catch (final Exception e) {
        throw new IllegalArgumentException("failed to fit aggregate model for point match quality calculation", e);
    }

    return qualityStats;
}
 
Example #6
Source File: ScriptUtil.java    From render with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Fits sampled points to a model.
 *
 * Stolen from
 *
 * <a href="https://github.com/axtimwalde/fiji-scripts/blob/master/TrakEM2/visualize-ct-difference.bsh#L90-L106">
 *     https://github.com/axtimwalde/fiji-scripts/blob/master/TrakEM2/visualize-ct-difference.bsh#L90-L106
 * </a>.
 *
 * @param  model                model to fit (note: model will be changed by this operation).
 * @param  coordinateTransform  transform to apply to each sampled point.
 * @param  sampleWidth          width of each sample.
 * @param  sampleHeight         height of each sample.
 * @param  samplesPerDimension  number of samples to take in each dimension.
 */
public static void fit(final Model<?> model,
                       final CoordinateTransform coordinateTransform,
                       final double sampleWidth,
                       final double sampleHeight,
                       final int samplesPerDimension)
        throws NotEnoughDataPointsException, IllDefinedDataPointsException {

    final List<PointMatch> matches = new ArrayList<>();

    for (int y = 0; y < samplesPerDimension; ++y) {
        final double sampleY = y * sampleHeight;
        for (int x = 0; x < samplesPerDimension; ++x) {
            final double sampleX = x * sampleWidth;
            final Point p = new Point(new double[]{sampleX, sampleY});
            p.apply(coordinateTransform);
            matches.add(new PointMatch(p, p));
        }
    }

    model.fit(matches);
}
 
Example #7
Source File: ImagePlusTimePoint.java    From Stitching with GNU General Public License v2.0 5 votes vote down vote up
public ImagePlusTimePoint( final ImagePlus imp, final int impId, final int timepoint, final Model model, final ImageCollectionElement element )
{
	super( model );
	this.imp = imp;
	this.impId = impId;
	this.timePoint = timepoint;
	this.element = element;
	
	if ( TranslationModel2D.class.isInstance( model ) )
		dimensionality = 2;
	else
		dimensionality = 3;
}
 
Example #8
Source File: DetectionRegistration.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Computes the RANSAC with reasonable parameters
 * @param correspondenceCandidates - the candidates
 * @param inlierList - the list of inliers that will be eventually populated
 * @param model - the model to use
 * @return the String that describes the result for feedback
 */
public static <S extends DetectionIdentification<S,T>, T extends DetectionView<S,T> > String computeRANSAC( 
		final ArrayList<PointMatchGeneric<T>> correspondenceCandidates, 
		final ArrayList<PointMatchGeneric<T>> inlierList, 
		final Model<?> model )
{
	return DetectionRegistration.<S,T>computeRANSAC( correspondenceCandidates, inlierList, model, 10, 0.1f, 3, 10000 );
}
 
Example #9
Source File: CanvasFeatureMatcher.java    From render with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param  canvas1Features  feature list for first canvas.
 * @param  canvas2Features  feature list for second canvas.
 *
 * @return match results for the specified feature lists.
 */
public CanvasFeatureMatchResult deriveMatchResult(final List<Feature> canvas1Features,
                                                  final List<Feature> canvas2Features) {

    LOG.info("deriveMatchResult: entry, canvas1Features.size={}, canvas2Features.size={}",
             canvas1Features.size(), canvas2Features.size());

    final Timer timer = new Timer();
    timer.start();

    final Model model = getModel();
    final List<PointMatch> candidates = new ArrayList<>(canvas1Features.size());

    FeatureTransform.matchFeatures(canvas1Features, canvas2Features, candidates, rod);

    CanvasFeatureMatchResult result = null;
    switch (filterType) {
        case NONE:
            result = new CanvasFeatureMatchResult(this, Collections.singletonList(candidates), candidates.size());
            break;
        case SINGLE_SET:
            final List<PointMatch> inliers = filterMatches(candidates, model);
            result = new CanvasFeatureMatchResult(this, Collections.singletonList(inliers), candidates.size());
            break;
        case CONSENSUS_SETS:
            final List<List<PointMatch>> consensusMatches = filterConsensusMatches(candidates);
            result = new CanvasFeatureMatchResult(this, consensusMatches, candidates.size());
            break;
        case AGGREGATED_CONSENSUS_SETS:
            final List<PointMatch> aggregatedMatches = new ArrayList<>(candidates.size());
            filterConsensusMatches(candidates).forEach(aggregatedMatches::addAll);

            result = new CanvasFeatureMatchResult(this, Collections.singletonList(aggregatedMatches), candidates.size());
            break;
    }

    LOG.info("deriveMatchResult: exit, result={}, elapsedTime={}s", result, (timer.stop() / 1000));

    return result;
}
 
Example #10
Source File: CanvasFeatureMatcher.java    From render with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return model instance for match filtering.
 */
public Model getModel() {
    final Model model;
    if (interpolatedModelLambda == null) {
        model = modelType.getInstance();
    } else {
        model = modelType.getInterpolatedInstance(regularizerModelType, interpolatedModelLambda);
    }
    return model;
}
 
Example #11
Source File: PointMatchQualityStats.java    From render with GNU General Public License v2.0 5 votes vote down vote up
public void calculate(final List<List<PointMatch>> consensusSetInliers,
                      final Model aggregateModel)
        throws NotEnoughDataPointsException, IllDefinedDataPointsException {

    consensusSetDeltaXStandardDeviations = new ArrayList<>();
    consensusSetDeltaYStandardDeviations = new ArrayList<>();
    aggregateDeltaXAndYStandardDeviation = new double[] { 0.0, 0.0 };

    final List<PointMatch> aggregatedInliers = new ArrayList<>();
    for (final List<PointMatch> consensusSet : consensusSetInliers) {
        if (consensusSet.size() > 0) {
            final double[] worldDeltaXAndYStandardDeviation = getWorldDeltaXAndYStandardDeviation(consensusSet);
            consensusSetDeltaXStandardDeviations.add(worldDeltaXAndYStandardDeviation[0]);
            consensusSetDeltaYStandardDeviations.add(worldDeltaXAndYStandardDeviation[1]);
            if (aggregateModel != null) {
                consensusSet.forEach(pm -> aggregatedInliers.add(new PointMatch(pm.getP1().clone(),
                                                                                pm.getP2().clone())));
            }
        }
    }

    if (aggregateModel == null) {
        if (consensusSetDeltaXStandardDeviations.size() > 0) {
            aggregateDeltaXAndYStandardDeviation = new double[]{
                    consensusSetDeltaXStandardDeviations.get(0),
                    consensusSetDeltaYStandardDeviations.get(0)
            };
        }
    } else {
        aggregateModel.fit(aggregatedInliers);
        this.aggregateDeltaXAndYStandardDeviation = getWorldDeltaXAndYStandardDeviation(aggregatedInliers);
    }
}
 
Example #12
Source File: RegularizedAffineLayerAlignment.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
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;
}
 
Example #13
Source File: ICPRefinement.java    From BigStitcher with GNU General Public License v2.0 4 votes vote down vote up
public static final HashMap< ViewId, mpicbg.models.Tile > pairSubset(
		final SpimData2 spimData,
		final Subset< ViewId > subset,
		final Map< ViewId, List< InterestPoint > > interestpoints,
		final Map< ViewId, String > labelMap,
		final IterativeClosestPointParameters icpp,
		final List< ViewId > fixedViews,
		final DemoLinkOverlay overlay )
{
	final List< Pair< ViewId, ViewId > > pairs = subset.getPairs();

	if ( pairs.size() <= 0 )
	{
		IOFunctions.println( "No image pair for comparison left, we need at least one pair for this to make sense." );
		return null;
	}

	for ( final Pair< ViewId, ViewId > pair : pairs )
		System.out.println( Group.pvid( pair.getA() ) + " <=> " + Group.pvid( pair.getB() ) );

	// compute all pairwise matchings
	final List< Pair< Pair< ViewId, ViewId >, PairwiseResult< InterestPoint > > > resultsPairs =
			MatcherPairwiseTools.computePairs( pairs, interestpoints, new IterativeClosestPointPairwise< InterestPoint >( icpp ) );

	if ( overlay != null )
	{
		final HashSet< Pair< Group< ViewId >, Group< ViewId > > > results = new HashSet<>();

		for ( final Pair< Pair< ViewId, ViewId >, PairwiseResult< InterestPoint > > result : resultsPairs  )
		{
			if ( result.getB().getInliers().size() > 0 )
			{
				results.add( new ValuePair< Group<ViewId>, Group<ViewId> >( new Group< ViewId >( result.getA().getA() ), new Group< ViewId >( result.getA().getB() ) ) );
			}
		}

		overlay.setPairwiseLinkInterface( new PairwiseLinkImpl( results ) );
	}

	// clear correspondences
	MatcherPairwiseTools.clearCorrespondences( subset.getViews(), spimData.getViewInterestPoints().getViewInterestPoints(), labelMap );

	// add the corresponding detections and output result
	for ( final Pair< Pair< ViewId, ViewId >, PairwiseResult< InterestPoint > > p : resultsPairs )
	{
		final ViewId vA = p.getA().getA();
		final ViewId vB = p.getA().getB();

		final InterestPointList listA = spimData.getViewInterestPoints().getViewInterestPoints().get( vA ).getInterestPointList( labelMap.get( vA ) );
		final InterestPointList listB = spimData.getViewInterestPoints().getViewInterestPoints().get( vB ).getInterestPointList( labelMap.get( vB ) );

		MatcherPairwiseTools.addCorrespondences( p.getB().getInliers(), vA, vB, labelMap.get( vA ), labelMap.get( vB ), listA, listB );

		IOFunctions.println( p.getB().getFullDesc() );
	}

	final ConvergenceStrategy cs = new ConvergenceStrategy( icpp.getMaxDistance() );
	final PointMatchCreator pmc = new InterestPointMatchCreator( resultsPairs );

	// run global optimization
	return (HashMap< ViewId, mpicbg.models.Tile >)GlobalOpt.compute( (Model)icpp.getModel().copy(), pmc, cs, fixedViews, subset.getGroups() );
}
 
Example #14
Source File: GlobalOptimizationSubset.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
protected < M extends Model< M > > AffineTransform3D computeMapBackModel( final HashMap< ViewId, Tile< M > > tiles, final GlobalOptimizationType type, final SpimData2 spimData )
{
	final AbstractModel< ? > mapBackModel = type.getMapBackModel();
	
	if ( mapBackModel.getMinNumMatches() > 4 )
	{
		IOFunctions.println( "Cannot map back using a model that needs more than 4 points: " + mapBackModel.getClass().getSimpleName() );

		return null;
	}
	else
	{
		IOFunctions.println( "Mapping back to reference frame using a " + mapBackModel.getClass().getSimpleName() );
		
		final ViewId referenceTile = type.getMapBackReferenceTile( this );
		final ViewDescription referenceTileViewDescription = spimData.getSequenceDescription().getViewDescription( referenceTile );
		final ViewSetup referenceTileSetup = referenceTileViewDescription.getViewSetup();
		Dimensions size = ViewSetupUtils.getSizeOrLoad( referenceTileSetup, referenceTileViewDescription.getTimePoint(), spimData.getSequenceDescription().getImgLoader() );
		long w = size.dimension( 0 );
		long h = size.dimension( 1 );

		final double[][] p = new double[][]{
				{ 0, 0, 0 },
				{ w, 0, 0 },
				{ 0, h, 0 },
				{ w, h, 0 } };

		// original coordinates == pa
		final double[][] pa = new double[ 4 ][ 3 ];
		
		// map coordinates to the actual input coordinates
		final ViewRegistration inputModel = spimData.getViewRegistrations().getViewRegistration( referenceTile );

		for ( int i = 0; i < p.length; ++i )
			inputModel.getModel().apply( p[ i ], pa[ i ] );
		
		final M outputModel = tiles.get( referenceTile ).getModel();
		
		// transformed coordinates == pb
		final double[][] pb = new double[ 4 ][ 3 ];

		for ( int i = 0; i < p.length; ++i )
			pb[ i ] = outputModel.apply( pa[ i ] );

		// compute the model that maps pb >> pa
		try
		{
			final ArrayList< PointMatch > pm = new ArrayList< PointMatch >();
			
			for ( int i = 0; i < p.length; ++i )
				pm.add( new PointMatch( new Point( pb[ i ] ), new Point( pa[ i ] ) ) );
			
			mapBackModel.fit( pm );
		} catch ( Exception e )
		{
			IOFunctions.println( "Could not compute model for mapping back: " + e );
			e.printStackTrace();
			return null;
		}

		final AffineTransform3D mapBack = new AffineTransform3D();
		final double[][] m = new double[ 3 ][ 4 ];
		((Affine3D<?>)mapBackModel).toMatrix( m );
		
		mapBack.set( m[0][0], m[0][1], m[0][2], + m[0][3],
					m[1][0], m[1][1], m[1][2], m[1][3], 
					m[2][0], m[2][1], m[2][2], m[2][3] );

		IOFunctions.println( "Model for mapping back: " + mapBack + "\n" );

		return mapBack;
	}
}
 
Example #15
Source File: GlobalOptimizationSubset.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param model
 * @param type
 * @param spimData
 * @param channelsToProcess - just to annotate the registration
 * @param description
 * @return
 */
public < M extends Model< M > > boolean computeGlobalOpt(
		final M model,
		final GlobalOptimizationType type,
		final SpimData2 spimData,
		final List< ChannelProcess > channelsToProcess,
		final String description )
{
	final HashMap< ViewId, Tile< M > > tiles = GlobalOpt.compute( model, type, this, type.considerTimePointsAsUnit() );

	if ( tiles == null )
		return false;
	
	String channelList = "[";
	for ( final ChannelProcess c : channelsToProcess )
		channelList += c.getLabel() + " (c=" + c.getChannel().getName() + "), ";
	channelList = channelList.substring( 0, channelList.length() - 2 ) + "]";

	final AffineTransform3D mapBackModel;
	
	// TODO: Map back first tile as good as possible to original location???
	if ( type.getMapBackReferenceTile( this ) != null && type.getMapBackModel() != null )
		mapBackModel = computeMapBackModel( tiles, type, spimData );
	else
		mapBackModel = null;

	// update the view registrations
	for ( final ViewId viewId : this.getViews() )
	{
		final Tile< M > tile = tiles.get( viewId );
		
		// TODO: we assume that M is an Affine3D, which is not necessarily true
		final Affine3D< ? > tilemodel = (Affine3D< ? >)tile.getModel();
		final double[][] m = new double[ 3 ][ 4 ];
		tilemodel.toMatrix( m );
		
		final AffineTransform3D t = new AffineTransform3D();
		t.set( m[0][0], m[0][1], m[0][2], m[0][3],
			   m[1][0], m[1][1], m[1][2], m[1][3],
			   m[2][0], m[2][1], m[2][2], m[2][3] );
		
		if ( mapBackModel != null )
		{
			t.preConcatenate( mapBackModel );
			IOFunctions.println( "ViewId=" + viewId.getViewSetupId() + ": " + t );
		}
		
		Apply_Transformation.preConcatenateTransform( spimData, viewId, t, description + " on " + channelList );
	}

	return true;
}
 
Example #16
Source File: RansacFilterClient.java    From render with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {

        final CanvasFeatureMatcher matcher = new CanvasFeatureMatcher(parameters.matchDerivation);

        final List<CanvasMatches> inlierCanvasMatchesLists = new ArrayList<>();

        for (final CanvasMatches pair : loadMatchData(parameters.candidateFile)) {

            final Model model = matcher.getModel();
            final List<PointMatch> candidates = new ArrayList<>(
                    CanvasFeatureMatchResult.convertMatchesToPointMatchList(pair.getMatches()));

            List<List<PointMatch>> inliersLists = new ArrayList<>();
            switch (parameters.matchDerivation.matchFilter) {
                case SINGLE_SET:
                    inliersLists = Collections.singletonList(matcher.filterMatches(candidates, model));
                    break;
                case CONSENSUS_SETS:
                    inliersLists = matcher.filterConsensusMatches(candidates);
                    break;
                case NONE:
                    throw new IllegalArgumentException("--matchFilter indicates no filtering needed");
            }

            final int numberOfConsensusSets = inliersLists.size();

            for (int i = 0; i < numberOfConsensusSets; i++) {
                final CanvasMatches filteredCanvasMatches;
                if (numberOfConsensusSets > 1) {
                    final String setSuffix = String.format("_set_%03d", i);
                    filteredCanvasMatches =
                        new CanvasMatches(pair.getpGroupId(),
                                          pair.getpId() + setSuffix,
                                          pair.getqGroupId(),
                                          pair.getqId() + setSuffix,
                                          CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i),
                                                                                                  1.0));
                    filteredCanvasMatches.setConsensusSetData(new ConsensusSetData(i, pair.getpId(), pair.getqId()));
                } else {
                    filteredCanvasMatches =
                            new CanvasMatches(pair.getpGroupId(),
                                              pair.getpId(),
                                              pair.getqGroupId(),
                                              pair.getqId(),
                                              CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i),
                                                                                                      1.0));
                }
                inlierCanvasMatchesLists.add(filteredCanvasMatches);
            }

        }

        final String[] sourceFileNameElements = splitFileName(parameters.candidateFile);
        final String baseName = sourceFileNameElements[0] + "_filtered";
        final String extension = sourceFileNameElements[1];
        final Path outputFilePath = Paths.get(parameters.outputDirectory, baseName + extension).toAbsolutePath();
        saveMatchData(inlierCanvasMatchesLists, outputFilePath.toString());

    }
 
Example #17
Source File: ICPRefinement.java    From BigStitcher with GNU General Public License v2.0 4 votes vote down vote up
public static HashMap< ViewId, mpicbg.models.Tile > groupedSubset(
		final SpimData2 spimData,
		final Subset< ViewId > subset,
		final Map< ViewId, List< InterestPoint > > interestpoints,
		final Map< ViewId, String > labelMap,
		final IterativeClosestPointParameters icpp,
		final List< ViewId > fixedViews,
		final DemoLinkOverlay overlay )
{
	final List< Pair< Group< ViewId >, Group< ViewId > > > groupedPairs = subset.getGroupedPairs();
	final Map< Group< ViewId >, List< GroupedInterestPoint< ViewId > > > groupedInterestpoints = new HashMap<>();
	final InterestPointGrouping< ViewId > ipGrouping = new InterestPointGroupingMinDistance<>( interestpoints );

	if ( groupedPairs.size() <= 0 )
	{
		IOFunctions.println( "No pair of grouped images for comparison left, we need at least one pair for this to make sense." );
		return null;
	}

	// which groups exist
	final Set< Group< ViewId > > groups = new HashSet<>();

	for ( final Pair< Group< ViewId >, Group< ViewId > > pair : groupedPairs )
	{
		groups.add( pair.getA() );
		groups.add( pair.getB() );

		System.out.print( "[" + pair.getA() + "] <=> [" + pair.getB() + "]" );

		if ( !groupedInterestpoints.containsKey( pair.getA() ) )
		{
			System.out.print( ", grouping interestpoints for " + pair.getA() );

			groupedInterestpoints.put( pair.getA(), ipGrouping.group( pair.getA() ) );
		}

		if ( !groupedInterestpoints.containsKey( pair.getB() ) )
		{
			System.out.print( ", grouping interestpoints for " + pair.getB() );

			groupedInterestpoints.put( pair.getB(), ipGrouping.group( pair.getB() ) );
		}

		System.out.println();
	}

	final List< Pair< Pair< Group< ViewId >, Group< ViewId > >, PairwiseResult< GroupedInterestPoint< ViewId > > > > resultsGroups =
			MatcherPairwiseTools.computePairs( groupedPairs, groupedInterestpoints, new IterativeClosestPointPairwise< GroupedInterestPoint< ViewId > >( icpp ) );

	if ( overlay != null )
	{
		final HashSet< Pair< Group< ViewId >, Group< ViewId > > > results = new HashSet<>();

		for ( final Pair< Pair< Group< ViewId >, Group< ViewId > >, PairwiseResult< GroupedInterestPoint< ViewId > > > result : resultsGroups  )
			if ( result.getB().getInliers().size() > 0 )
				results.add( result.getA() );

		overlay.setPairwiseLinkInterface( new PairwiseLinkImpl( results ) );
	}

	// clear correspondences and get a map linking ViewIds to the correspondence lists
	final Map< ViewId, List< CorrespondingInterestPoints > > cMap = MatcherPairwiseTools.clearCorrespondences( subset.getViews(), spimData.getViewInterestPoints().getViewInterestPoints(), labelMap );

	// add the corresponding detections and output result
	final List< Pair< Pair< ViewId, ViewId >, PairwiseResult< GroupedInterestPoint< ViewId > > > > resultG =
			MatcherPairwiseTools.addCorrespondencesFromGroups( resultsGroups, spimData.getViewInterestPoints().getViewInterestPoints(), labelMap, cMap );

	// run global optimization
	final ConvergenceStrategy cs = new ConvergenceStrategy( 10.0 );
	final PointMatchCreator pmc = new InterestPointMatchCreator( resultG );

	return (HashMap< ViewId, mpicbg.models.Tile >)GlobalOpt.compute( (Model)icpp.getModel().copy(), pmc, cs, fixedViews, groups );
}
 
Example #18
Source File: ComparePair.java    From Stitching with GNU General Public License v2.0 votes vote down vote up
public Model< ? > getModel2() { return impB.getModel(); } 
Example #19
Source File: ComparePair.java    From Stitching with GNU General Public License v2.0 votes vote down vote up
public Model< ? > getModel1() { return impA.getModel(); } 
Example #20
Source File: ImageCollectionElement.java    From Stitching with GNU General Public License v2.0 votes vote down vote up
public Model<?> getModel() { return model; } 
Example #21
Source File: ImageCollectionElement.java    From Stitching with GNU General Public License v2.0 votes vote down vote up
public void setModel( final Model<?> model ) { this.model = model; }