public FingerprintTemplate(byte[,] image, int dpi = 500) { const int blockSize = 15; if (dpi != 500) { image = ScaleImage(image, dpi); } image = InvertInput(image); var blocks = new BlockMap(new Point(image.GetLength(1), image.GetLength(0)), blockSize); var histogram = ComputeHistogram(blocks, image); var smoothHistogram = ComputeSmoothedHistogram(blocks, histogram); var mask = ComputeMask(blocks, histogram); double[,] equalized = Equalize(blocks, image, smoothHistogram, mask); byte[,] orientation = ComputeOrientationMap(equalized, mask, blocks); double[,] smoothed = SmoothByOrientation(equalized, orientation, mask, blocks, 0, ConstructOrientedLines(step: 1.59)); double[,] orthogonal = SmoothByOrientation(smoothed, orientation, mask, blocks, Angle.PIB, ConstructOrientedLines(resolution: 11, radius: 4, step: 1.11)); var binary = Binarize(smoothed, orthogonal, mask, blocks); CleanupBinarized(binary); BitmapUtils.ShowImage(binary); var pixelMask = FillBlocks(mask, blocks); var innerMask = ComputeInnerMask(pixelMask); var inverted = Invert(binary, pixelMask); FingerprintSkeleton ridges = new FingerprintSkeleton(binary); FingerprintSkeleton valleys = new FingerprintSkeleton(inverted); CollectMinutiae(ridges, FingerprintMinutiaType.Ending); CollectMinutiae(valleys, FingerprintMinutiaType.Bifurcation); ApplyMask(innerMask); RemoveMinutiaClouds(); LimitTemplateSize(); ShuffleMinutiae(); BuildEdgeTable(); }
void CollectMinutiae(FingerprintSkeleton skeleton, FingerprintMinutiaType type) { foreach (SkeletonMinutia skeletonMinutia in skeleton.Minutiae) { if (skeletonMinutia.IsConsidered && skeletonMinutia.Ridges.Count == 1) { FingerprintMinutia templateMinutia = new FingerprintMinutia(); templateMinutia.Type = type; templateMinutia.Position = skeletonMinutia.Position; templateMinutia.Direction = skeletonMinutia.Ridges[0].ComputeDirection(); Minutiae.Add(templateMinutia); } } }