internal JYMtiaDescriptor(SkeletonImage skeletonImage, List <Minutia> minutiae, short mainMtiaIdx, short mtiaIdx0, short mtiaIdx1) { this.minutiae = minutiae; this.mainMtiaIdx = mainMtiaIdx; nearestMtiaIdx = mtiaIdx0; farthestMtiaIdx = mtiaIdx1; MtiaEuclideanDistance dist = new MtiaEuclideanDistance(); dist0 = dist.Compare(MainMinutia, NearestMtia); dist1 = dist.Compare(MainMinutia, FarthestMtia); if (dist1 < dist0) { nearestMtiaIdx = mtiaIdx1; farthestMtiaIdx = mtiaIdx0; double temp = dist0; dist0 = dist1; dist1 = temp; } alpha0 = ComputeAlpha(MainMinutia, NearestMtia); alpha1 = ComputeAlpha(MainMinutia, FarthestMtia); beta0 = ComputeBeta(MainMinutia, NearestMtia); beta1 = ComputeBeta(MainMinutia, FarthestMtia); ridgeCount0 = ComputeRidgeCount(skeletonImage, MainMinutia, NearestMtia); ridgeCount1 = ComputeRidgeCount(skeletonImage, MainMinutia, FarthestMtia); }
internal JiangMinutiaDescriptor(SkeletonImage skeletonImage, List <Minutia> minutiae, short mainMtiaIdx, short mtiaIdx0, short mtiaIdx1) { Minutiae = minutiae; MainMtiaIdx = mainMtiaIdx; NearestMtiaIdx = mtiaIdx0; FarthestMtiaIdx = mtiaIdx1; Dist0 = MtiaEuclideanDistance.Compare(MainMinutia, NearestMtia); Dist1 = MtiaEuclideanDistance.Compare(MainMinutia, FarthestMtia); if (Dist1 < Dist0) { NearestMtiaIdx = mtiaIdx1; FarthestMtiaIdx = mtiaIdx0; var temp = Dist0; Dist0 = Dist1; Dist1 = temp; } Alpha0 = ComputeAlpha(MainMinutia, NearestMtia); Alpha1 = ComputeAlpha(MainMinutia, FarthestMtia); Beta0 = ComputeBeta(MainMinutia, NearestMtia); Beta1 = ComputeBeta(MainMinutia, FarthestMtia); RidgeCount0 = ComputeRidgeCount(skeletonImage, MainMinutia, NearestMtia); RidgeCount1 = ComputeRidgeCount(skeletonImage, MainMinutia, FarthestMtia); }
private Int16[] GetNearest(List <Minutia> minutiae, Minutia query) { double[] distances = new double[neighborsCount]; Int16[] nearestM = new Int16[neighborsCount]; for (int i = 0; i < distances.Length; i++) { distances[i] = double.MaxValue; } MtiaEuclideanDistance dist = new MtiaEuclideanDistance(); for (Int16 i = 0; i < minutiae.Count; i++) { if (minutiae[i] != query) { double CurrentDistance = dist.Compare(query, minutiae[i]); int MaxIdx = 0; for (int j = 1; j < neighborsCount; j++) { if (distances[j] > distances[MaxIdx]) { MaxIdx = j; } } if (CurrentDistance < distances[MaxIdx]) { distances[MaxIdx] = CurrentDistance; nearestM[MaxIdx] = i; } } } return(nearestM); }
private static bool MatchDistance(Minutia refQuery, Minutia refTemplate, Minutia query, Minutia template) { var d0 = MtiaEuclideanDistance.Compare(refQuery, query); var d1 = MtiaEuclideanDistance.Compare(refTemplate, template); return(Math.Abs(d0 - d1) <= GlobalDistThr); }
private static void UpdateNearest(IList <Minutia> minutiae, int idx, short[,] nearest, double[,] distance) { for (var i = idx + 1; i < minutiae.Count; i++) { var dValue = MtiaEuclideanDistance.Compare(minutiae[idx], minutiae[i]); var maxIdx = 0; for (var j = 1; j < NeighborsCount; j++) { if (distance[idx, j] > distance[idx, maxIdx]) { maxIdx = j; } } if (dValue < distance[idx, maxIdx]) { distance[idx, maxIdx] = dValue; nearest[idx, maxIdx] = Convert.ToInt16(i); } maxIdx = 0; for (var j = 1; j < NeighborsCount; j++) { if (distance[i, j] > distance[i, maxIdx]) { maxIdx = j; } } if (dValue < distance[i, maxIdx]) { distance[i, maxIdx] = dValue; nearest[i, maxIdx] = Convert.ToInt16(idx); } } }
private static short[] GetNearest(IReadOnlyList <Minutia> minutiae, Minutia query) { var distances = new double[NeighborsCount]; var nearestM = new short[NeighborsCount]; for (var i = 0; i < distances.Length; i++) { distances[i] = Double.MaxValue; } for (short i = 0; i < minutiae.Count; i++) { if (minutiae[i] != query) { var currentDistance = MtiaEuclideanDistance.Compare(query, minutiae[i]); var maxIdx = 0; for (var j = 1; j < NeighborsCount; j++) { if (distances[j] > distances[maxIdx]) { maxIdx = j; } } if (currentDistance < distances[maxIdx]) { distances[maxIdx] = currentDistance; nearestM[maxIdx] = i; } } } return(nearestM); }
private List <MinutiaPair> GetGlobalMatchingMtiae(List <MinutiaPair> localMatchingPairs, MinutiaPair refMtiaPair, ref int notMatchingCount) { var globalMatchingMtiae = new List <MinutiaPair>(localMatchingPairs.Count); var qMatches = new Dictionary <Minutia, Minutia>(localMatchingPairs.Count); var tMatches = new Dictionary <Minutia, Minutia>(localMatchingPairs.Count); qMatches.Add(refMtiaPair.QueryMtia, refMtiaPair.TemplateMtia); tMatches.Add(refMtiaPair.TemplateMtia, refMtiaPair.QueryMtia); var mm = new MtiaMapper(refMtiaPair.QueryMtia, refMtiaPair.TemplateMtia); var currNotMatchingMtiaCount = 0; int i; for (i = 0; i < localMatchingPairs.Count; i++) { var mtiaPair = localMatchingPairs[i]; if (!qMatches.ContainsKey(mtiaPair.QueryMtia) && !tMatches.ContainsKey(mtiaPair.TemplateMtia)) { var query = mm.Map(mtiaPair.QueryMtia); var template = mtiaPair.TemplateMtia; if (MtiaEuclideanDistance.Compare(query, template) <= GlobalDistThr && MatchDirections(query, template)) { globalMatchingMtiae.Add(mtiaPair); qMatches.Add(mtiaPair.QueryMtia, mtiaPair.TemplateMtia); tMatches.Add(mtiaPair.TemplateMtia, mtiaPair.QueryMtia); } else { currNotMatchingMtiaCount++; } } if (currNotMatchingMtiaCount >= notMatchingCount) { break; } //if (globalMatchingMtiae.Count + (localMatchingPairs.Count - i - 1) < MtiaCountThr) // break; } if (i != localMatchingPairs.Count) { return(null); } notMatchingCount = currNotMatchingMtiaCount; globalMatchingMtiae.Add(refMtiaPair); return(globalMatchingMtiae); }
public MinutiaTriplet(short[] mIdxs, List <Minutia> minutiae) { Minutiae = minutiae; MtiaIdxs = mIdxs; var mtiaArr = new Minutia[3]; mtiaArr[0] = minutiae[MtiaIdxs[0]]; mtiaArr[1] = minutiae[MtiaIdxs[1]]; mtiaArr[2] = minutiae[MtiaIdxs[2]]; D[0] = MtiaEuclideanDistance.Compare(mtiaArr[0], mtiaArr[1]); D[1] = MtiaEuclideanDistance.Compare(mtiaArr[1], mtiaArr[2]); D[2] = MtiaEuclideanDistance.Compare(mtiaArr[0], mtiaArr[2]); }
private List <Minutia> GetMinutiaes(ImageMatrix matrix, OrientationImage orientationImage) { List <Minutia> minutiaes = new List <Minutia>(); for (int row = 0; row < orientationImage.Height; row++) { for (int col = 0; col < orientationImage.Width; col++) { if (!orientationImage.IsNullBlock(row, col)) { int x, y; orientationImage.GetPixelCoordFromBlock(row, col, out x, out y); int maxLength = orientationImage.WindowSize / 2; for (int xi = x - maxLength; xi < x + maxLength; xi++) { for (int yi = y - maxLength; yi < y + maxLength; yi++) { if (xi > 0 && xi < matrix.Width - 1 && yi > 0 && yi < matrix.Height - 1) { if (matrix[yi, xi] == 0) { List <int> values = new List <int> { matrix[yi, xi + 1] == 255 ? 0 : 1, matrix[yi - 1, xi + 1] == 255 ? 0 : 1, matrix[yi - 1, xi] == 255 ? 0 : 1, matrix[yi - 1, xi - 1] == 255 ? 0 : 1, matrix[yi, xi - 1] == 255 ? 0 : 1, matrix[yi + 1, xi - 1] == 255 ? 0 : 1, matrix[yi + 1, xi] == 255 ? 0 : 1, matrix[yi + 1, xi + 1] == 255 ? 0 : 1, }; int cn = 0; for (int i = 0; i < values.Count; i++) { int idx = i; if (i == 7) { idx = -1; } cn += Math.Abs(values[i] - values[idx + 1]); } cn = (int)(cn * 0.5); double angleminu; // end minutiae if (cn == 1) { angleminu = GetMinutiaeAngle(matrix, xi, yi, MinutiaType.End); if (angleminu != -1) { minutiaes.Add(new Minutia { Angle = (float)angleminu, X = (short)xi, Y = (short)yi, MinutiaType = MinutiaType.End } ); } } //bifurcation minutiae if (cn == 3) { angleminu = GetMinutiaeAngle(matrix, xi, yi, MinutiaType.Bifurcation); if (!double.IsNaN(angleminu) && angleminu != -1) { minutiaes.Add(new Minutia { Angle = (float)angleminu, X = (short)xi, Y = (short)yi, MinutiaType = MinutiaType.Bifurcation } ); } } } } } } } } } List <Minutia> noInTheBorder = new List <Minutia>(); for (int i = 0; i < minutiaes.Count; i++) { // boundary Effects (foreground areas) int row, col; orientationImage.GetBlockCoordFromPixel(minutiaes[i].X, minutiaes[i].Y, out row, out col); if (row >= 1 && col >= 1 && col < orientationImage.Width - 1 && row < orientationImage.Height - 1) { if (! (orientationImage.IsNullBlock(row - 1, col) || orientationImage.IsNullBlock(row + 1, col) || orientationImage.IsNullBlock(row, col - 1) || orientationImage.IsNullBlock(row, col + 1) //|| ) ) { noInTheBorder.Add(minutiaes[i]); } } } MtiaEuclideanDistance miEuclideanDistance = new MtiaEuclideanDistance(); bool[] toErase = new bool[noInTheBorder.Count]; for (int i = 0; i < noInTheBorder.Count; i++) { Minutia mA = noInTheBorder[i]; for (int j = 0; j < noInTheBorder.Count; j++) { if (i != j) { Minutia mB = noInTheBorder[j]; // different to orientation image int row, col; orientationImage.GetBlockCoordFromPixel(mA.X, mA.Y, out row, out col); double angleOI = orientationImage.AngleInRadians(row, col); if (mA.MinutiaType == MinutiaType.End && Math.Min(Angle.DifferencePi(mA.Angle, angleOI), Angle.DifferencePi(mA.Angle, angleOI + Math.PI)) > Math.PI / 6) { toErase[i] = true; } // near minutiaes elimination if (mA.MinutiaType == mB.MinutiaType && miEuclideanDistance.Compare(mA, mB) < 5) { toErase[i] = toErase[j] = true; } // Ridge break elimination (Ratha) if (mA.MinutiaType == MinutiaType.End && mB.MinutiaType == MinutiaType.End && mA.Angle == mB.Angle && miEuclideanDistance.Compare(mA, mB) < 10) { toErase[i] = toErase[j] = true; } // Ridge break elimination (tavo - migue) if (mA.MinutiaType == MinutiaType.End && mB.MinutiaType == MinutiaType.End && Angle.DifferencePi(mA.Angle, mB.Angle) < Math.PI / 12 && miEuclideanDistance.Compare(mA, mB) < 10) { toErase[i] = toErase[j] = true; } // spike elimination if (mA.MinutiaType == MinutiaType.End && mB.MinutiaType == MinutiaType.Bifurcation && miEuclideanDistance.Compare(mA, mB) < 15) { if (RemoveSpikeOnMinutiae(matrix, mA, mB)) { toErase[i] = true; } } } } } List <Minutia> result = new List <Minutia>(); for (int i = 0; i < noInTheBorder.Count; i++) { if (!toErase[i]) { result.Add(noInTheBorder[i]); } } return(result); }