Пример #1
0
        public static void CalculateAverageAndMaximumAccel(AcceleratorTarget acceleratorTarget, float[,] imageData, out float average, out float maximum)
        {
            var target = GetAcceleratorTarget(acceleratorTarget);

            int width  = imageData.GetLength(0);
            int height = imageData.GetLength(1);

            var fpInput = new FloatParallelArray(imageData);

            var fpAverage = ParallelArrays.Sum(fpInput);

            fpAverage = ParallelArrays.Divide(fpAverage, (float)(width * height));
            fpAverage = ParallelArrays.Pad(fpAverage, new int[] { 0 }, new int[] { 1 }, 0.0f);

            var fpMaximum = ParallelArrays.MaxVal(fpInput);

            fpMaximum = ParallelArrays.Pad(fpMaximum, new int[] { 1 }, new int[] { 0 }, 0.0f);

            var fpOutput = ParallelArrays.Add(fpAverage, fpMaximum);

            var output = target.ToArray1D(fpOutput);

            average = output[0];
            maximum = output[1];
        }