Accord.Imaging.IntegralImage2.GetSumT C# (CSharp) Method

GetSumT() public method

Gets the sum of the pixels in a tilted rectangle of the Integral image.
public GetSumT ( int x, int y, int width, int height ) : long
x int The horizontal position of the rectangle x.
y int The vertical position of the rectangle y.
width int The rectangle's width w.
height int The rectangle's height h.
return long
        public long GetSumT(int x, int y, int width, int height)
        {
            int a = tWidth * (y + width) + (x + width + 1);
            int b = tWidth * (y + height) + (x - height + 1);
            int c = tWidth * (y) + (x + 1);
            int d = tWidth * (y + width + height) + (x + width - height + 1);

            return tSum[a] + tSum[b] - tSum[c] - tSum[d];
        }

Usage Example

Example #1
0
        /// <summary>
        ///   Gets the sum of the areas of the rectangular features in an integral image.
        /// </summary>
        /// 
        public double GetSum(IntegralImage2 image, int x, int y)
        {
            double sum = 0.0;

            if (!Tilted)
            {
                // Compute the sum for a standard feature
                foreach (HaarRectangle rect in Rectangles)
                {
                    sum += image.GetSum(x + rect.ScaledX, y + rect.ScaledY,
                        rect.ScaledWidth, rect.ScaledHeight) * rect.ScaledWeight;
                }
            }
            else
            {
                // Compute the sum for a rotated feature
                foreach (HaarRectangle rect in Rectangles)
                {
                    sum += image.GetSumT(x + rect.ScaledX, y + rect.ScaledY,
                        rect.ScaledWidth, rect.ScaledHeight) * rect.ScaledWeight;
                }
            }

            return sum;
        }