示例#1
0
        float[, ,] ComputeEqualization(BlockMap blocks, short[, ,] histogram, BinaryMap blockMask)
        {
            float widthMax = RangeSize / 256f * MaxScaling;
            float widthMin = RangeSize / 256f * MinScaling;

            float[] limitedMin = new float[256];
            float[] limitedMax = new float[256];
            for (int i = 0; i < 256; ++i)
            {
                limitedMin[i] = Math.Max(i * widthMin + RangeMin, RangeMax - (255 - i) * widthMax);
                limitedMax[i] = Math.Min(i * widthMax + RangeMin, RangeMax - (255 - i) * widthMin);
            }

            float[, ,] equalization = new float[blocks.CornerCount.Height, blocks.CornerCount.Width, 256];
            Parallel.ForEach(blocks.AllCorners, delegate(Point corner)
            {
                if (blockMask.GetBitSafe(corner.X, corner.Y, false) ||
                    blockMask.GetBitSafe(corner.X - 1, corner.Y, false) ||
                    blockMask.GetBitSafe(corner.X, corner.Y - 1, false) ||
                    blockMask.GetBitSafe(corner.X - 1, corner.Y - 1, false))
                {
                    int area = 0;
                    for (int i = 0; i < 256; ++i)
                    {
                        area += histogram[corner.Y, corner.X, i];
                    }
                    float widthWeigth = RangeSize / area;

                    float top = RangeMin;
                    for (int i = 0; i < 256; ++i)
                    {
                        float width     = histogram[corner.Y, corner.X, i] * widthWeigth;
                        float equalized = top + ToFloatTable[i] * width;
                        top            += width;

                        float limited = equalized;
                        if (limited < limitedMin[i])
                        {
                            limited = limitedMin[i];
                        }
                        if (limited > limitedMax[i])
                        {
                            limited = limitedMax[i];
                        }
                        equalization[corner.Y, corner.X, i] = limited;
                    }
                }
            });
            return(equalization);
        }
示例#2
0
 public void Filter(TemplateBuilder template, BinaryMap mask)
 {
     template.Minutiae.RemoveAll(minutia =>
     {
         var arrow = Calc.Round(-DirectedExtension * Angle.ToVector(minutia.Direction));
         return(!mask.GetBitSafe((Point)minutia.Position + new Size(arrow), false));
     });
     Logger.Log(template);
 }
示例#3
0
        void TraceRidges(BinaryMap binary, Dictionary <Point, SkeletonBuilder.Minutia> minutiaePoints)
        {
            Dictionary <Point, SkeletonBuilder.Ridge> leads = new Dictionary <Point, SkeletonBuilder.Ridge>();

            foreach (Point minutiaPoint in minutiaePoints.Keys)
            {
                foreach (Point startRelative in Neighborhood.CornerNeighbors)
                {
                    Point start = Calc.Add(minutiaPoint, startRelative);
                    if (binary.GetBitSafe(start, false) && !minutiaePoints.ContainsKey(start) && !leads.ContainsKey(start))
                    {
                        SkeletonBuilder.Ridge ridge = new SkeletonBuilder.Ridge();
                        ridge.Points.Add(minutiaPoint);
                        ridge.Points.Add(start);
                        Point previous = minutiaPoint;
                        Point current  = start;
                        do
                        {
                            Point next = new Point();
                            foreach (Point nextRelative in Neighborhood.CornerNeighbors)
                            {
                                next = Calc.Add(current, nextRelative);
                                if (binary.GetBitSafe(next, false) && next != previous)
                                {
                                    break;
                                }
                            }
                            AssertException.Check(next != new Point());
                            previous = current;
                            current  = next;
                            ridge.Points.Add(current);
                        } while (!minutiaePoints.ContainsKey(current));
                        Point end = current;

                        ridge.Start                     = minutiaePoints[minutiaPoint];
                        ridge.End                       = minutiaePoints[end];
                        leads[ridge.Points[1]]          = ridge;
                        leads[ridge.Reversed.Points[1]] = ridge;
                    }
                }
            }
        }