Exemplo n.º 1
0
 /// <summary>
 ///  投影
 /// </summary>
 /// <param name="data">二维数据</param>
 /// <param name="width">数据宽度</param>
 /// <param name="height">数据高度</param>
 /// <param name="orientType">投影的方向(水平或垂直)</param>
 /// <param name="average">是否去平均值</param>
 /// <param name="result">投影的结果</param>
 protected void projection(ref Byte[] data, Int32 width, Int32 height, ValueImage.Infrastructure.OrientationType orientType, Boolean average, out Int32[] result)
 {
     if (orientType == Infrastructure.OrientationType.Horizontal)
     {
         result = new Int32[height];
         for (int i = 0; i < height; i++)
         {
             for (int j = 0; j < width; j++)
             {
                 result[i] += data[i * width + j];
             }
             if (average)
             {
                 result[i] /= width;
             }
         }
     }
     else if (orientType == Infrastructure.OrientationType.Vertical)
     {
         result = new Int32[width];
         for (int i = 0; i < width; i++)
         {
             for (int j = 0; j < height; j++)
             {
                 result[i] += data[j * width + i];
             }
             if (average)
             {
                 result[i] /= height;
             }
         }
     }
     else
     {
         result = new Int32[0];
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///  投影
        /// </summary>
        protected void projection(ref Byte[] data, Int32 width, Int32 height, Double angle, ValueImage.Infrastructure.OrientationType orientType, out Int32[] result)
        {
            if (angle == System.Math.PI / 2)
            {
                projection(ref data, width, height, orientType, false, out result);
                return;
            }

            if (orientType == OrientationType.Horizontal)
            {
                result = new Int32[height];
                for (int j = 0; j < height; j++)
                {
                    for (int i = 0; i < width; i++)
                    {
                        Int32 y = ((Int32)((Double)i / System.Math.Tan(angle)) + j);

                        if (y >= 0 && y < height)
                        {
                            result[y] += data[j * width + i];
                        }
                    }
                }
            }
            else if (orientType == OrientationType.Vertical)
            {
                result = new Int32[width];
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        Int32 x = ((Int32)((Double)j / System.Math.Tan(angle)) + i);
                        if (x >= 0 && x < width)
                        {
                            result[j * width + x] += data[j * width + i];
                        }
                    }
                }
            }
            else
            {
                result = new Int32[0];
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///  投影
 /// </summary>
 /// <param name="data">二维数据</param>
 /// <param name="width">数据宽度</param>
 /// <param name="height">数据高度</param>
 /// <param name="orientType">投影的方向(水平或垂直)</param>
 /// <param name="result">投影的结果</param>
 protected void projection(ref Byte[] data, Int32 width, Int32 height, ValueImage.Infrastructure.OrientationType orientType, out Int32[] result)
 {
     this.projection(ref data, width, height, orientType, true, out result);
 }