internal Qi2005Features(List<Minutia> minutiae, OrientationImage dImg) { Minutiae = new List<GOwMtia>(minutiae.Count); foreach (Minutia mtia in minutiae) { Minutiae.Add(new GOwMtia(mtia, dImg)); } }
internal Tico2003Features(List<Minutia> minutiae, OrientationImage dImg) { Minutiae = new List<OBMtiaDescriptor>(minutiae.Count); for (short i = 0; i < minutiae.Count; i++) { OBMtiaDescriptor mtiaDescriptor = new OBMtiaDescriptor(minutiae[i], dImg); Minutiae.Add(mtiaDescriptor); } }
internal GOwMtia(Minutia mnt, OrientationImage dImg) { Minutia = mnt; Segments = new Segment[6]; for (int i = 0; i < Segments.Length; i++) { Segments[i] = new Segment(i * (2 * Math.PI / 6) + mnt.Angle, mnt, dImg); } }
/// <summary> /// Decodes an <see cref="OrientationImage"/> from a byte array. /// </summary> /// <remarks> /// This codification stores <see cref="OrientationImage.Width"/> in the first byte; <see cref="OrientationImage.Height"/> in the second byte; <see cref="OrientationImage.Width"/> in the third byte; and uses one byte for each orientation value. Therefore, this method is ineffective for values of <see cref="OrientationImage.WindowSize"/>, <see cref="OrientationImage.Height"/> and <see cref="OrientationImage.Width"/> greater than 255. /// </remarks> /// <param name="bytes">The byte array containing the encoded <see cref="OrientationImage"/>.</param> /// <returns>The <see cref="OrientationImage"/> decoded from the specified byte array.</returns> public static OrientationImage FromByteArray(byte[] bytes) { byte height = bytes[1]; byte width = bytes[2]; byte[,] orientations = new byte[height, width]; for (int i = 0; i < height; i++) for (int j = 0; j < width; j++) orientations[i, j] = Convert.ToByte(bytes[i * width + j + 3]); OrientationImage orImg = new OrientationImage(width, height, orientations, bytes[0]); return orImg; }
/// <summary> /// Encodes the specified <see cref="OrientationImage"/> into a byte array. /// </summary> /// <remarks> /// This codification stores <see cref="OrientationImage.Width"/> in the first byte; <see cref="OrientationImage.Height"/> in the second byte; <see cref="OrientationImage.Width"/> in the third byte; and uses one byte for each orientation value. Therefore, this method is ineffective for values of <see cref="OrientationImage.WindowSize"/>, <see cref="OrientationImage.Height"/> and <see cref="OrientationImage.Width"/> greater than 255. /// </remarks> /// <param name="orImg">The <see cref="OrientationImage"/> which is going to be encoded to a byte array.</param> /// <returns>The byte array containing the encoded <see cref="OrientationImage"/>.</returns> public static byte[] ToByteArray(OrientationImage orImg) { byte[] bytes = new byte[orImg.Width * orImg.Height + 3]; bytes[0] = orImg.WindowSize; bytes[1] = orImg.Height; bytes[2] = orImg.Width; int k = 3; for (int i = 0; i < orImg.Height; i++) for (int j = 0; j < orImg.Width; j++) if (orImg.IsNullBlock(i, j)) bytes[k++] = 255; else bytes[k++] = Convert.ToByte(Math.Round(orImg.AngleInRadians(i, j) * 180 / Math.PI)); return bytes; }
/// <summary> /// Decodes an <see cref="OrientationImage"/> from a byte array. /// </summary> /// <remarks> /// This codification stores <see cref="OrientationImage.Width"/> in the first byte; <see cref="OrientationImage.Height"/> in the second byte; <see cref="OrientationImage.Width"/> in the third byte; and uses one byte for each orientation value. Therefore, this method is ineffective for values of <see cref="OrientationImage.WindowSize"/>, <see cref="OrientationImage.Height"/> and <see cref="OrientationImage.Width"/> greater than 255. /// </remarks> /// <param name="bytes">The byte array containing the encoded <see cref="OrientationImage"/>.</param> /// <returns>The <see cref="OrientationImage"/> decoded from the specified byte array.</returns> public static OrientationImage FromByteArray(byte[] bytes) { byte height = bytes[1]; byte width = bytes[2]; byte[,] orientations = new byte[height, width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { orientations[i, j] = Convert.ToByte(bytes[i * width + j + 3]); } } OrientationImage orImg = new OrientationImage(width, height, orientations, bytes[0]); return(orImg); }
internal OBMtiaDescriptor(Minutia mnt, OrientationImage dImg) { Minutia = mnt; //difRadio = (int) Math.Truncate((Resolution/25.4)*ridgePeriod*2); EmptyFeaturesCount = 0; Orientations = new double[72]; for (int i = 0, j = 0; i < 4; i++) { var curr = GetOrientations(initRadio + i * difRadio, Minutia, dImg); for (int k = 0; k < curr.Length; k++) { Orientations[j++] = curr[k]; if (double.IsNaN(curr[k])) EmptyFeaturesCount++; } } }
private double[] GetOrientations(int radio, Minutia mtia, OrientationImage dirImg) { double[] currOrientations = new double[radio / 3]; int n = radio / 3; double incAng = 2 * Math.PI * 3.0 / radio; for (int i = 0; i < n; i++) { double myAng = mtia.Angle + i * incAng; if (myAng > 2 * Math.PI) myAng -= (double)(2 * Math.PI); Point pnt = SetPosToSPoint(myAng, radio, new Point(mtia.X, mtia.Y)); int row, col; dirImg.GetBlockCoordFromPixel(pnt.X, pnt.Y, out row, out col); if ((col < 0) || (row < 0) || (row >= dirImg.Height) || (col >= dirImg.Width) || (dirImg.IsNullBlock(row, col))) currOrientations[i] = double.NaN; else currOrientations[i] = Math.Min(Angle.DifferencePi(mtia.Angle, dirImg.AngleInRadians(row, col)), Angle.DifferencePi(mtia.Angle, dirImg.AngleInRadians(row, col) + Math.PI)); } return currOrientations; }
internal Segment(double ang, Minutia mnt, OrientationImage dImg) { bool endOfPoints = false; int i = 1; List<double> points = new List<double>(); while (!endOfPoints) { Point pnt = SetPosToSPoint(ang, i*interval, new Point(mnt.X, mnt.Y)); if (IsInBound(pnt, dImg)) { int row, col; dImg.GetBlockCoordFromPixel(pnt.X, pnt.Y, out row, out col); if ((col < 0) || (row < 0) || (row >= dImg.Height) || (col >= dImg.Width) || (dImg.IsNullBlock(row, col))) points.Add(double.NaN); else points.Add(Math.Min(Angle.DifferencePi(mnt.Angle, dImg.AngleInRadians(row, col)), Angle.DifferencePi(mnt.Angle, dImg.AngleInRadians(row, col) + Math.PI))); i++; } else endOfPoints = true; } bool isLastNan = false; int j = points.Count - 1; while (!isLastNan && j >= 0) { if (double.IsNaN(points[j])) { points.RemoveAt(j); j--; } else isLastNan = true; } directions = points.ToArray(); }
/// <summary> /// Encodes the specified <see cref="OrientationImage"/> into a byte array. /// </summary> /// <remarks> /// This codification stores <see cref="OrientationImage.Width"/> in the first byte; <see cref="OrientationImage.Height"/> in the second byte; <see cref="OrientationImage.Width"/> in the third byte; and uses one byte for each orientation value. Therefore, this method is ineffective for values of <see cref="OrientationImage.WindowSize"/>, <see cref="OrientationImage.Height"/> and <see cref="OrientationImage.Width"/> greater than 255. /// </remarks> /// <param name="orImg">The <see cref="OrientationImage"/> which is going to be encoded to a byte array.</param> /// <returns>The byte array containing the encoded <see cref="OrientationImage"/>.</returns> public static byte[] ToByteArray(OrientationImage orImg) { byte[] bytes = new byte[orImg.Width * orImg.Height + 3]; bytes[0] = orImg.WindowSize; bytes[1] = orImg.Height; bytes[2] = orImg.Width; int k = 3; for (int i = 0; i < orImg.Height; i++) { for (int j = 0; j < orImg.Width; j++) { if (orImg.IsNullBlock(i, j)) { bytes[k++] = 255; } else { bytes[k++] = Convert.ToByte(Math.Round(orImg.AngleInRadians(i, j) * 180 / Math.PI)); } } } return(bytes); }
/// <summary> /// Save the specified <see cref="OrientationImage"/> to the specified file name. /// </summary> /// <remarks> /// Before saving, the <see cref="OrientationImage"/> is encoded using the method <see cref="ToByteArray"/>. /// </remarks> /// <param name="fileName">The file name where the specified <see cref="OrientationImage"/> will be saved.</param> /// <param name="orImg">The <see cref="OrientationImage"/> to be saved.</param> public static void Serialize(string fileName, OrientationImage orImg) { var byteArr = ToByteArray(orImg); File.WriteAllBytes(fileName, byteArr); }
internal bool IsInBound(Point pnt, OrientationImage dImg) { if (pnt.X > 0 && pnt.X < dImg.Width * dImg.WindowSize && pnt.Y > 0 && pnt.Y < dImg.Height * dImg.WindowSize) return true; return false; }