Exemple #1
0
        private static List <MatchingPair> FindMatchingPairs(NeighborEdge[] probeStar, NeighborEdge[] candidateStar)
        {
            var complementaryAngleError = Angle.Complementary(MaxAngleError);
            var results = new List <MatchingPair>();
            var range   = new Range();

            foreach (var candidateEdge in candidateStar)
            {
                while (range.Begin < probeStar.Length &&
                       probeStar[range.Begin].Edge.Length < candidateEdge.Edge.Length - MaxDistanceError)
                {
                    ++range.Begin;
                }
                if (range.End < range.Begin)
                {
                    range.End = range.Begin;
                }
                while (range.End < probeStar.Length &&
                       probeStar[range.End].Edge.Length <= candidateEdge.Edge.Length + MaxDistanceError)
                {
                    ++range.End;
                }

                for (var probeIndex = range.Begin; probeIndex < range.End; ++probeIndex)
                {
                    var probeEdge     = probeStar[probeIndex];
                    var referenceDiff =
                        Angle.Difference(probeEdge.Edge.ReferenceAngle, candidateEdge.Edge.ReferenceAngle);
                    if (referenceDiff <= MaxAngleError || referenceDiff >= complementaryAngleError)
                    {
                        var neighborDiff = Angle.Difference(probeEdge.Edge.NeighborAngle,
                                                            candidateEdge.Edge.NeighborAngle);
                        if (neighborDiff <= MaxAngleError || neighborDiff >= complementaryAngleError)
                        {
                            results.Add(new MatchingPair
                            {
                                Pair = new MinutiaPair
                                {
                                    Probe     = probeEdge.Neighbor,
                                    Candidate = candidateEdge.Neighbor
                                },
                                Distance = candidateEdge.Edge.Length
                            });
                        }
                    }
                }
            }

            return(results);
        }
        private static PointF[,] ComputePixelwiseOrientation(double[,] input, bool[,] mask, BlockMap blocks)
        {
            var neighbors = GetTestedOrientations();

            var orientation = new PointF[input.GetLength(0), input.GetLength(1)];

            for (var blockY = 0; blockY < blocks.BlockCount.Y; ++blockY)
            {
                var validMaskRange = GetMaskLineRange(mask, blockY);
                if (validMaskRange.Length > 0)
                {
                    var validXRange = new Range(blocks.BlockAreas[blockY, validMaskRange.Begin].Left,
                                                blocks.BlockAreas[blockY, validMaskRange.End - 1].Right);
                    for (var y = blocks.BlockAreas[blockY, 0].Bottom; y < blocks.BlockAreas[blockY, 0].Top; ++y)
                    {
                        foreach (var neighbor in neighbors[y % neighbors.Count])
                        {
                            var radius = Math.Max((sbyte)Math.Abs(neighbor.CheckLocation.X),
                                                  (sbyte)Math.Abs(neighbor.CheckLocation.Y));
                            if (y - radius < 0 || y + radius >= input.GetLength(0))
                            {
                                continue;
                            }
                            var xRange = new Range(Math.Max(radius, validXRange.Begin),
                                                   Math.Min(input.GetLength(1) - radius, validXRange.End));
                            for (var x = xRange.Begin; x < xRange.End; ++x)
                            {
                                var before   = input[y - neighbor.CheckLocation.Y, x - neighbor.CheckLocation.X];
                                var at       = input[y, x];
                                var after    = input[y + neighbor.CheckLocation.Y, x + neighbor.CheckLocation.X];
                                var strength = at - Math.Max(before, after);
                                if (strength > 0)
                                {
                                    orientation[y, x] = orientation[y, x] + strength * neighbor.OrientationVector;
                                }
                            }
                        }
                    }
                }
            }

            return(orientation);
        }