@Override public Sampler< T > getSampler() { return getSampler( 0 ); }
@Override public Sampler< T > getSampler() { return getSampler( 0 ); }
public static < I extends InterestPoint > ArrayList< TranslationInvariantLocalCoordinateSystemPointDescriptor< I > > createLocalCoordinateSystemPointDescriptors( final KDTree< I > tree, final ArrayList< I > basisPoints, final int redundancy ) { final int[][] neighborIndicies = SubsetMatcher.computePD( 3 + redundancy, 3, 1 ); final KNearestNeighborSearchOnKDTree< I > nnsearch = new KNearestNeighborSearchOnKDTree<>( tree, 3 + redundancy + 1 ); final ArrayList< TranslationInvariantLocalCoordinateSystemPointDescriptor< I > > descriptors = new ArrayList<> ( ); for ( final I p : basisPoints ) { nnsearch.search( p ); for ( final int[] neighbors : neighborIndicies ) { final I point1 = nnsearch.getSampler( neighbors[ 0 ] ).get(); final I point2 = nnsearch.getSampler( neighbors[ 1 ] ).get(); final I point3 = nnsearch.getSampler( neighbors[ 2 ] ).get(); try { descriptors.add( new TranslationInvariantLocalCoordinateSystemPointDescriptor< I >( p, point1, point2, point3 ) ); } catch ( NoSuitablePointsException e ) { e.printStackTrace(); } } } return descriptors; }
protected static < I extends InterestPoint > ArrayList< SimplePointDescriptor< I > > createSimplePointDescriptors( final KDTree< I > tree, final ArrayList< I > basisPoints, final int numNeighbors, final Matcher matcher, final SimilarityMeasure similarityMeasure ) { final KNearestNeighborSearchOnKDTree< I > nnsearch = new KNearestNeighborSearchOnKDTree<>( tree, numNeighbors + 1 ); final ArrayList< SimplePointDescriptor< I > > descriptors = new ArrayList<> ( ); for ( final I p : basisPoints ) { final ArrayList< I > neighbors = new ArrayList<>(); nnsearch.search( p ); // the first hit is always the point itself for ( int n = 1; n < numNeighbors + 1; ++n ) neighbors.add( nnsearch.getSampler( n ).get() ); try { descriptors.add( new SimplePointDescriptor< I >( p, neighbors, similarityMeasure, matcher ) ); } catch ( NoSuitablePointsException e ) { e.printStackTrace(); } } return descriptors; }
protected void computeMatching( final ArrayList< TranslationInvariantLocalCoordinateSystemPointDescriptor< I > > descriptors1, final KNearestNeighborSearchOnKDTree< TranslationInvariantLocalCoordinateSystemPointDescriptor< I > > nnsearch2, final ArrayList< PointMatchGeneric< I > > correspondences, final double ratioOfDistance ) { final HashSet< Pair< I, I > > pairs = new HashSet<>(); int count = 0; for ( final TranslationInvariantLocalCoordinateSystemPointDescriptor< I > descriptorA : descriptors1 ) { nnsearch2.search( descriptorA ); double best = descriptorA.descriptorDistance( nnsearch2.getSampler( 0 ).get() ); double secondBest = descriptorA.descriptorDistance( nnsearch2.getSampler( 1 ).get() ); if ( best * ratioOfDistance <= secondBest ) { final I detectionA = descriptorA.getBasisPoint(); final I detectionB = nnsearch2.getSampler( 0 ).get().getBasisPoint(); // twice the same pair could potentially show up due to redundancy pairs.add( new ValuePair<>( detectionA, detectionB ) ); ++count; } } for ( final Pair< I, I > pair : pairs ) correspondences.add( new PointMatchGeneric< I >( pair.getA(), pair.getB(), 1 ) ); System.out.println( count + " <> " + correspondences.size() ); }
neighborPoints.add( nnsearch.getSampler( neighbors[ n ] ).get() );
protected void computeMatching( final ArrayList< LocalCoordinateSystemPointDescriptor< I > > descriptors1, final KNearestNeighborSearchOnKDTree< LocalCoordinateSystemPointDescriptor< I > > nnsearch2, final ArrayList< PointMatchGeneric< I > > correspondences, final double differenceThreshold, final double ratioOfDistance ) { final HashSet< Pair< I, I > > pairs = new HashSet<>(); //System.out.println( "BeadA" + "\t" + "BeadB1" + "\t" + "BeadB2" + "\t" + "Diff1" + "\t" + "Diff2" ); for ( final LocalCoordinateSystemPointDescriptor< I > descriptorA : descriptors1 ) { nnsearch2.search( descriptorA ); double best = descriptorA.descriptorDistance( nnsearch2.getSampler( 0 ).get() ); double secondBest = descriptorA.descriptorDistance( nnsearch2.getSampler( 1 ).get() ); if ( best < differenceThreshold && best * ratioOfDistance <= secondBest ) { final I detectionA = descriptorA.getBasisPoint(); final I detectionB = nnsearch2.getSampler( 0 ).get().getBasisPoint(); //System.out.println( beadA.getID() + "\t" + matches[ 0 ].getBasisPoint().getID() + "\t" + matches[ 1 ].getBasisPoint().getID() + "\t" + best + "\t" + secondBest ); //detectionA.addPointDescriptorCorrespondence( detectionB, 1 ); //detectionB.addPointDescriptorCorrespondence( detectionA, 1 ); // twice the same pair could potentially show up due to redundancy pairs.add( new ValuePair<>( detectionA, detectionB ) ); //correspondences.add( new PointMatchGeneric< I >( detectionA, detectionB, 1 ) ); } } for ( final Pair< I, I > pair : pairs ) correspondences.add( new PointMatchGeneric< I >( pair.getA(), pair.getB(), 1 ) ); }
for ( int i = 0; i < neighbors; ++i ) nnKdtree[ i ] = kd.getSampler( i ).get(); for ( int i = 0; i < neighbors; ++i ) nnKdtree[ i ] = kd.getSampler( i ).get(); nnKdtree[ i ].getClass();