Пример #1
0
    // Find the nearest neighbour to the hyperspace point 'target' within the
    // kd-tree. After return 'resDist' contains the absolute distance from the
    // target point. The nearest neighbour is returned.
    public IKDTreeDomain NearestNeighbour(IKDTreeDomain target, out double resDist)
    {
        HyperRectangle hr = HyperRectangle.CreateUniverseRectangle(target.DimensionCount);

        IKDTreeDomain nearest = NearestNeighbourI(target, hr, Double.PositiveInfinity, out resDist);

        resDist = Math.Sqrt(resDist);

        return(nearest);
    }
Пример #2
0
    // Limited Best-Bin-First k-d-tree nearest neighbour search.
    //
    // (Using the algorithm described in the paper "Shape indexing using
    // approximate nearest-neighbour search in high-dimensional spaces",
    // available at http://www.cs.ubc.ca/spider/lowe/papers/cvpr97-abs.html)
    //
    // Find the approximate nearest neighbour to the hyperspace point 'target'
    // within the kd-tree using 'searchSteps' tail recursions at most (each
    // recursion deciding about one neighbours' fitness).
    //
    // After return 'resDist' contains the absolute distance of the
    // approximate nearest neighbour from the target point. The approximate
    // nearest neighbour is returned.
    public ArrayList NearestNeighbourListBBF(IKDTreeDomain target, int q, int searchSteps)
    {
        HyperRectangle hr = HyperRectangle.CreateUniverseRectangle(target.DimensionCount);

        SortedLimitedList best     = new SortedLimitedList(q);
        SortedLimitedList searchHr = new SortedLimitedList(searchSteps);

        float         dummyDist;
        IKDTreeDomain nearest = NearestNeighbourListBBFI(best, q, target, hr, float.MaxValue, out dummyDist, searchHr, ref searchSteps);

        foreach (BestEntry be in best)
        {
            be.Distance = Math.Sqrt(be.DistanceSq);
        }

        return(best);
    }
Пример #3
0
    public ArrayList NearestNeighbourList(IKDTreeDomain target, out double resDist, int q)
    {
        HyperRectangle hr =
            HyperRectangle.CreateUniverseRectangle(target.DimensionCount);

        SortedLimitedList best = new SortedLimitedList(q);

        IKDTreeDomain nearest = NearestNeighbourListI(best, q, target, hr,
                                                      Double.PositiveInfinity, out resDist);

        resDist = Math.Sqrt(resDist);

        foreach (BestEntry be in best)
        {
            be.Distance = Math.Sqrt(be.Distance);
        }

        return(best);
    }