/// <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;
 }
Пример #2
0
        /// <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);
        }
 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;
 }
Пример #4
0
 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();
 }