Esempio n. 1
0
        public static YDataFloat GenerateEdgeDetectedImageAccel(AcceleratorTarget acceleratorTarget, YDataFloat imageData)
        {
            var target = GetAcceleratorTarget(acceleratorTarget);

            var width  = imageData.Width;
            var height = imageData.Height;

            var fpInput = new FloatParallelArray(imageData.Data);

            var fpInputX = ParallelArrays.Shift(fpInput, new int[] { 1, 0 });
            var fpInputY = ParallelArrays.Shift(fpInput, new int[] { 0, 1 });

            var fpDX     = ParallelArrays.Subtract(fpInputX, fpInput);
            var fpDY     = ParallelArrays.Subtract(fpInputY, fpInput);
            var fpTotals = ParallelArrays.Add(fpDX, fpDY);

            var fpOutput = ParallelArrays.Divide(fpTotals, 2.0f);

            fpOutput = ParallelArrays.Add(fpOutput, imageData.MaximumValue / 2.0f);
            fpOutput = ParallelArrays.Max(fpOutput, 0.0f);
            fpOutput = ParallelArrays.Min(fpOutput, imageData.MaximumValue);

            var output = target.ToArray2D(fpOutput);

            return(new YDataFloat(output, imageData.MaximumValue));
        }