Пример #1
0
        /// <summary>
        /// Computes a sum of the values in the array starting at (<paramref name="row"/>, <paramref name="column"/>) in <paramref name="channel" />
        /// in a rectangle described by the offset and size in <paramref name="rect"/>.
        /// </summary>
        /// <param name="handler">The handler used to perform the operation</param>
        /// <param name="row">Reference row</param>
        /// <param name="column">Reference column</param>
        /// <param name="channel">Channel to draw values from</param>
        /// <param name="rect">Offset and size of the rectangle</param>
        /// <returns>The sum of all values in the rectangle</returns>
        public static T ComputeRectangleSum <T>(this IArrayHandler <T> handler, int row, int column, int channel, Rectangle rect)
        {
            int startRow    = row + rect.Top;
            int startColumn = column + rect.Left;
            int rows        = rect.Height;
            int columns     = rect.Width;

            return(handler.ComputeRectangleSum(startRow, startColumn, rows, columns, channel));
        }
Пример #2
0
            public float Compute(ImageDataPoint <float> point)
            {
                if (point.ImageID != _currentID)
                {
                    _currentID = point.ImageID;
                    if (point.Image.IsIntegral || DecisionTree <ImageDataPoint <float>, float[]> .IsBuilding)
                    {
                        _integralImage = point.Image;
                    }
                    else
                    {
                        _integralImage = IntegralImage.ComputeFloat <FloatArrayHandler>(point.Image);
                    }
                }
                int   row    = point.Row;
                int   column = point.Column;
                float sum    = _integralImage.ComputeRectangleSum(row, column, _channel, _rect);

                Debug.Assert(!float.IsNaN(sum), "Rectangle sum is NaN");
                return(sum);
            }