public object Clone() { SkeletonBuilder clone = new SkeletonBuilder(); Dictionary <Minutia, Minutia> minutiaClones = new Dictionary <Minutia, Minutia>(); foreach (Minutia minutia in AllMinutiae) { Minutia minutiaClone = new Minutia(minutia.Position); minutiaClone.Valid = minutia.Valid; clone.AddMinutia(minutiaClone); minutiaClones[minutia] = minutiaClone; } Dictionary <Ridge, Ridge> ridgeClones = new Dictionary <Ridge, Ridge>(); foreach (Minutia minutia in AllMinutiae) { foreach (Ridge ridge in minutia.Ridges) { if (!ridgeClones.ContainsKey(ridge)) { Ridge ridgeClone = new Ridge(); ridgeClone.Start = minutiaClones[ridge.Start]; ridgeClone.End = minutiaClones[ridge.End]; foreach (Point point in ridge.Points) { ridgeClone.Points.Add(point); } ridgeClones[ridge] = ridgeClone; ridgeClones[ridge.Reversed] = ridgeClone.Reversed; } } } return(clone); }
Dictionary <Point, SkeletonBuilder.Minutia> ComputeMinutiaCenters(Dictionary <Point, List <Point> > linking, SkeletonBuilder skeleton) { Dictionary <Point, SkeletonBuilder.Minutia> centers = new Dictionary <Point, SkeletonBuilder.Minutia>(); foreach (Point currentPos in linking.Keys) { List <Point> linkedMinutiae = linking[currentPos]; Point primaryPos = linkedMinutiae[0]; if (!centers.ContainsKey(primaryPos)) { Point sum = new Point(); foreach (Point linkedPos in linkedMinutiae) { sum = Calc.Add(sum, linkedPos); } Point center = new Point(sum.X / linkedMinutiae.Count, sum.Y / linkedMinutiae.Count); SkeletonBuilder.Minutia minutia = new SkeletonBuilder.Minutia(center); skeleton.AddMinutia(minutia); centers[primaryPos] = minutia; } centers[currentPos] = centers[primaryPos]; } return(centers); }