static DoublePointMatrix SmoothOrientation(DoublePointMatrix orientation, BooleanMatrix mask) { var size = mask.Size; var smoothed = new DoublePointMatrix(size); foreach (var block in size.Iterate()) { if (mask[block]) { var neighbors = IntRect.Around(block, Parameters.OrientationSmoothingRadius).Intersect(new IntRect(size)); for (int ny = neighbors.Top; ny < neighbors.Bottom; ++ny) { for (int nx = neighbors.Left; nx < neighbors.Right; ++nx) { if (mask[nx, ny]) { smoothed.Add(block, orientation[nx, ny]); } } } } } // https://sourceafis.machinezoo.com/transparency/smoothed-orientation FingerprintTransparency.Current.Log("smoothed-orientation", smoothed); return(smoothed); }
static DoubleMatrix OrientationAngles(DoublePointMatrix vectors, BooleanMatrix mask) { var size = mask.Size; var angles = new DoubleMatrix(size); foreach (var block in size.Iterate()) { if (mask[block]) { angles[block] = DoubleAngle.Atan(vectors[block]); } } return(angles); }
static DoublePointMatrix PixelwiseOrientation(DoubleMatrix input, BooleanMatrix mask, BlockMap blocks) { var neighbors = PlanOrientations(); var orientation = new DoublePointMatrix(input.Size); for (int blockY = 0; blockY < blocks.Primary.Blocks.Y; ++blockY) { var maskRange = MaskRange(mask, blockY); if (maskRange.Length > 0) { var validXRange = new IntRange( blocks.Primary.Block(maskRange.Start, blockY).Left, blocks.Primary.Block(maskRange.End - 1, blockY).Right); for (int y = blocks.Primary.Block(0, blockY).Top; y < blocks.Primary.Block(0, blockY).Bottom; ++y) { foreach (var neighbor in neighbors[y % neighbors.Length]) { int radius = Math.Max(Math.Abs(neighbor.Offset.X), Math.Abs(neighbor.Offset.Y)); if (y - radius >= 0 && y + radius < input.Height) { var xRange = new IntRange(Math.Max(radius, validXRange.Start), Math.Min(input.Width - radius, validXRange.End)); for (int x = xRange.Start; x < xRange.End; ++x) { double before = input[x - neighbor.Offset.X, y - neighbor.Offset.Y]; double at = input[x, y]; double after = input[x + neighbor.Offset.X, y + neighbor.Offset.Y]; double strength = at - Math.Max(before, after); if (strength > 0) { orientation.Add(x, y, strength * neighbor.Orientation); } } } } } } } // https://sourceafis.machinezoo.com/transparency/pixelwise-orientation FingerprintTransparency.Current.Log("pixelwise-orientation", orientation); return(orientation); }
static DoublePointMatrix BlockOrientations(DoublePointMatrix orientation, BlockMap blocks, BooleanMatrix mask) { var sums = new DoublePointMatrix(blocks.Primary.Blocks); foreach (var block in blocks.Primary.Blocks.Iterate()) { if (mask[block]) { var area = blocks.Primary.Block(block); for (int y = area.Top; y < area.Bottom; ++y) { for (int x = area.Left; x < area.Right; ++x) { sums.Add(block, orientation[x, y]); } } } } // https://sourceafis.machinezoo.com/transparency/block-orientation FingerprintTransparency.Current.Log("block-orientation", sums); return(sums); }