예제 #1
0
 static bool IsFalseEnding(BinaryMap binary, Point ending)
 {
     foreach (Point relativeNeighbor in Neighborhood.CornerNeighbors)
     {
         Point neighbor = Calc.Add(ending, relativeNeighbor);
         if (binary.GetBit(neighbor))
         {
             return(Calc.CountBits(binary.GetNeighborhood(neighbor)) > 2);
         }
     }
     return(false);
 }
예제 #2
0
        List <Point> FindMinutiae(BinaryMap binary)
        {
            List <Point> result = new List <Point>();

            for (int y = 0; y < binary.Height; ++y)
            {
                for (int x = 0; x < binary.Width; ++x)
                {
                    if (binary.GetBit(x, y) && IsMinutia[binary.GetNeighborhood(x, y)])
                    {
                        result.Add(new Point(x, y));
                    }
                }
            }
            return(result);
        }
예제 #3
0
        public BinaryMap Thin(BinaryMap input)
        {
            BinaryMap intermediate = new BinaryMap(input.Size);

            intermediate.Copy(input, new RectangleC(1, 1, input.Width - 2, input.Height - 2), new Point(1, 1));

            BinaryMap border          = new BinaryMap(input.Size);
            BinaryMap skeleton        = new BinaryMap(input.Size);
            bool      removedAnything = true;

            for (int i = 0; i < MaxIterations && removedAnything; ++i)
            {
                removedAnything = false;
                for (int j = 0; j < 4; ++j)
                {
                    border.Copy(intermediate);
                    switch (j)
                    {
                    case 0:
                        border.AndNot(intermediate, new RectangleC(1, 0, border.Width - 1, border.Height), new Point(0, 0));
                        break;

                    case 1:
                        border.AndNot(intermediate, new RectangleC(0, 0, border.Width - 1, border.Height), new Point(1, 0));
                        break;

                    case 2:
                        border.AndNot(intermediate, new RectangleC(0, 1, border.Width, border.Height - 1), new Point(0, 0));
                        break;

                    case 3:
                        border.AndNot(intermediate, new RectangleC(0, 0, border.Width, border.Height - 1), new Point(0, 1));
                        break;
                    }
                    border.AndNot(skeleton);

                    for (int odd = 0; odd < 2; ++odd)
                    {
                        Parallel.For(1, input.Height - 1, delegate(int y)
                        {
                            if (y % 2 == odd)
                            {
                                for (int xw = 0; xw < input.WordWidth; ++xw)
                                {
                                    if (border.IsWordNonZero(xw, y))
                                    {
                                        for (int x = xw << BinaryMap.WordShift; x < (xw << BinaryMap.WordShift) + BinaryMap.WordSize; ++x)
                                        {
                                            if (x > 0 && x < input.Width - 1 && border.GetBit(x, y))
                                            {
                                                uint neighbors = intermediate.GetNeighborhood(x, y);
                                                if (IsRemovable[neighbors] ||
                                                    IsEnding[neighbors] && IsFalseEnding(intermediate, new Point(x, y)))
                                                {
                                                    removedAnything = true;
                                                    intermediate.SetBitZero(x, y);
                                                }
                                                else
                                                {
                                                    skeleton.SetBitOne(x, y);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        });
                    }
                }
            }

            Logger.Log(skeleton);
            return(skeleton);
        }