final NearestNeighborSearchOnKDTree< InterestPoint > search = new NearestNeighborSearchOnKDTree<>( kdTreeTiff ); search.search( ipHdf5 ); if ( search.getDistance() < 4 ) pairs.add( new ValuePair<>( search.getSampler().get(), ipHdf5 ) ); dist += search.getDistance(); maxDist = Math.max( search.getDistance(), maxDist ); median.add( search.getDistance() );
@Override public void search( final RealLocalizable p ) { p.localize( pos ); bestSquDistance = Double.MAX_VALUE; searchNode( tree.getRoot() ); }
@Override public ArrayList< PointMatchGeneric< LinkedInterestPoint< P > > > assignPointMatches( final List< LinkedInterestPoint< P > > target, final List< LinkedInterestPoint< P > > reference ) { final ArrayList< PointMatchGeneric< LinkedInterestPoint< P > > > pointMatches = new ArrayList<>(); final KDTree< LinkedInterestPoint< P > > kdTreeTarget = new KDTree<>( target, target ); final NearestNeighborSearchOnKDTree< LinkedInterestPoint< P > > nnSearchTarget = new NearestNeighborSearchOnKDTree<>( kdTreeTarget ); for ( final LinkedInterestPoint< P > point : reference ) { nnSearchTarget.search( point ); final LinkedInterestPoint< P > correspondingPoint = nnSearchTarget.getSampler().get(); // world coordinates of point if ( Point.distance( correspondingPoint, point ) <= distanceThresold ) pointMatches.add( new PointMatchGeneric< LinkedInterestPoint< P > >( correspondingPoint, point ) ); } return pointMatches; } }
/** * Creates a {@link RealPointCollection} with the points in the * {@link KDTree}. * * @param tree * KDTree which all the contains the desired points. The values * at each node in the tree will be ignored, only the positions * will be used. The first point determines the dimensionality of * the collection. Points cannot be added or removed. */ public KDTreeRealPointCollection( final KDTree< L > tree ) { super( tree, new NearestNeighborSearchOnKDTree<>( tree ) ); }
final NearestNeighborSearchOnKDTree< RealPoint > nn = new NearestNeighborSearchOnKDTree< RealPoint >( tree ); nn.search( p ); distances.add( nn.getDistance() );
@Override public NearestNeighborSearchOnKDTree< T > copy() { final NearestNeighborSearchOnKDTree< T > copy = new NearestNeighborSearchOnKDTree< T >( tree ); System.arraycopy( pos, 0, copy.pos, 0, pos.length ); copy.bestPoint = bestPoint; copy.bestSquDistance = bestSquDistance; return copy; } }
final NearestNeighborSearchOnKDTree< RealPoint > kd = new NearestNeighborSearchOnKDTree< RealPoint >( kdTree ); final long kdSetupTime = System.currentTimeMillis() - start; System.out.println( "kdtree setup took: " + ( kdSetupTime ) + " ms." ); kd.search( t ); final RealPoint nnKdtree = kd.getSampler().get(); final RealPoint nnExhaustive = findNearestNeighborExhaustive( points, t ); for ( final RealPoint t : testpoints ) kd.search( t ); final RealPoint nnKdtree = kd.getSampler().get(); nnKdtree.getClass();
final NearestNeighborSearchOnKDTree< RealPoint > nn = new NearestNeighborSearchOnKDTree< RealPoint >( tree ); final InterestPointList newIpl = new InterestPointList( oldIpl.getBaseDir(), nn.search( p ); final double d = nn.getDistance();
@Override public NearestNeighborSearchOnKDTree< T > copy() { final NearestNeighborSearchOnKDTree< T > copy = new NearestNeighborSearchOnKDTree< T >( tree ); System.arraycopy( pos, 0, copy.pos, 0, pos.length ); copy.bestPoint = bestPoint; copy.bestSquDistance = bestSquDistance; return copy; } }
@Override public void search( final RealLocalizable p ) { p.localize( pos ); bestSquDistance = Double.MAX_VALUE; searchNode( tree.getRoot() ); }
public RealRandomAccessible< FloatType > getRealRandomAccessible() { final NearestNeighborSearch< FloatType > search = new NearestNeighborSearchOnKDTree<>( new KDTree<>( qualityList ) ); return Views.interpolate( search, new NearestNeighborSearchInterpolatorFactory< FloatType >() ); }
protected void searchNode( final KDTreeNode< T > current ) { // consider the current node final double distance = current.squDistanceTo( pos ); if ( distance < bestSquDistance ) { bestSquDistance = distance; bestPoint = current; } final double axisDiff = pos[ current.getSplitDimension() ] - current.getSplitCoordinate(); final double axisSquDistance = axisDiff * axisDiff; final boolean leftIsNearBranch = axisDiff < 0; // search the near branch final KDTreeNode< T > nearChild = leftIsNearBranch ? current.left : current.right; final KDTreeNode< T > awayChild = leftIsNearBranch ? current.right : current.left; if ( nearChild != null ) searchNode( nearChild ); // search the away branch - maybe if ( ( axisSquDistance <= bestSquDistance ) && ( awayChild != null ) ) searchNode( awayChild ); }
public RandomAccessibleInterval< FloatType > getRandomAccessibleInterval() { // InverseDistanceWeightingInterpolatorFactory final NearestNeighborSearch< FloatType > search = new NearestNeighborSearchOnKDTree<>( new KDTree<>( qualityList ) ); final RealRandomAccessible< FloatType > realRandomAccessible = Views.interpolate( search, new NearestNeighborSearchInterpolatorFactory< FloatType >() ); final RandomAccessible< FloatType > randomAccessible = Views.raster( realRandomAccessible ); final RandomAccessibleInterval< FloatType > rai = Views.interval( randomAccessible, interval ); return Views.interval( Views.extendZero( rai ), interval ); }
protected void searchNode( final KDTreeNode< T > current ) { // consider the current node final double distance = current.squDistanceTo( pos ); if ( distance < bestSquDistance ) { bestSquDistance = distance; bestPoint = current; } final double axisDiff = pos[ current.getSplitDimension() ] - current.getSplitCoordinate(); final double axisSquDistance = axisDiff * axisDiff; final boolean leftIsNearBranch = axisDiff < 0; // search the near branch final KDTreeNode< T > nearChild = leftIsNearBranch ? current.left : current.right; final KDTreeNode< T > awayChild = leftIsNearBranch ? current.right : current.left; if ( nearChild != null ) searchNode( nearChild ); // search the away branch - maybe if ( ( axisSquDistance <= bestSquDistance ) && ( awayChild != null ) ) searchNode( awayChild ); }
drawNearestNeighbor( img, new NearestNeighborSearchOnKDTree< ARGBType >( kdtreeMatches ), new NearestNeighborSearchOnKDTree< ARGBType >( kdtreeMask ) );
drawNearestNeighbor( img, new NearestNeighborSearchOnKDTree< ARGBType >( kdtreeMatches ), new NearestNeighborSearchOnKDTree< ARGBType >( kdtreeMask ) );