Beispiel #1
0
        static bool IsWithinGapLimits(SkeletonMinutia end1, SkeletonMinutia end2)
        {
            int distanceSq = (end1.Position - end2.Position).LengthSq;

            if (distanceSq <= Integers.Sq(Parameters.MaxRuptureSize))
            {
                return(true);
            }
            if (distanceSq > Integers.Sq(Parameters.MaxGapSize))
            {
                return(false);
            }
            double gapDirection = DoubleAngle.Atan(end1.Position, end2.Position);
            double direction1   = DoubleAngle.Atan(end1.Position, AngleSampleForGapRemoval(end1));

            if (DoubleAngle.Distance(direction1, DoubleAngle.Opposite(gapDirection)) > Parameters.MaxGapAngle)
            {
                return(false);
            }
            double direction2 = DoubleAngle.Atan(end2.Position, AngleSampleForGapRemoval(end2));

            if (DoubleAngle.Distance(direction2, gapDirection) > Parameters.MaxGapAngle)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        static DoubleMatrix OrientationAngles(DoublePointMatrix vectors, BooleanMatrix mask)
        {
            var size   = mask.Size;
            var angles = new DoubleMatrix(size);

            foreach (var block in size.Iterate())
            {
                if (mask[block])
                {
                    angles[block] = DoubleAngle.Atan(vectors[block]);
                }
            }
            return(angles);
        }
Beispiel #3
0
        public double Direction()
        {
            int first = Parameters.RidgeDirectionSkip;
            int last  = Parameters.RidgeDirectionSkip + Parameters.RidgeDirectionSample - 1;

            if (last >= Points.Count)
            {
                int shift = last - Points.Count + 1;
                last  -= shift;
                first -= shift;
            }
            if (first < 0)
            {
                first = 0;
            }
            return(DoubleAngle.Atan(Points[first], Points[last]));
        }
Beispiel #4
0
 static EdgeShape()
 {
     for (int y = 0; y < PolarCacheRadius; ++y)
     {
         for (int x = 0; x < PolarCacheRadius; ++x)
         {
             PolarDistanceCache[y * PolarCacheRadius + x] = Doubles.RoundToInt(Math.Sqrt(Doubles.Sq(x) + Doubles.Sq(y)));
             if (y > 0 || x > 0)
             {
                 PolarAngleCache[y * PolarCacheRadius + x] = DoubleAngle.Atan(x, y);
             }
             else
             {
                 PolarAngleCache[y * PolarCacheRadius + x] = 0;
             }
         }
     }
 }
Beispiel #5
0
        static ConsideredOrientation[][] PlanOrientations()
        {
            var random = new OrientationRandom();
            var splits = new ConsideredOrientation[Parameters.OrientationSplit][];

            for (int i = 0; i < Parameters.OrientationSplit; ++i)
            {
                var orientations = splits[i] = new ConsideredOrientation[Parameters.OrientationsChecked];
                for (int j = 0; j < Parameters.OrientationsChecked; ++j)
                {
                    var sample = orientations[j] = new ConsideredOrientation();
                    while (true)
                    {
                        double angle    = random.Next() * Math.PI;
                        double distance = Doubles.InterpolateExponential(Parameters.MinOrientationRadius, Parameters.MaxOrientationRadius, random.Next());
                        sample.Offset = (distance * DoubleAngle.ToVector(angle)).Round();
                        if (sample.Offset == IntPoint.Zero)
                        {
                            continue;
                        }
                        if (sample.Offset.Y < 0)
                        {
                            continue;
                        }
                        bool duplicate = false;
                        for (int jj = 0; jj < j; ++jj)
                        {
                            if (orientations[jj].Offset == sample.Offset)
                            {
                                duplicate = true;
                            }
                        }
                        if (duplicate)
                        {
                            continue;
                        }
                        break;
                    }
                    sample.Orientation = DoubleAngle.ToVector(DoubleAngle.Add(DoubleAngle.ToOrientation(DoubleAngle.Atan((DoublePoint)sample.Offset)), Math.PI));
                }
            }
            return(splits);
        }