Exemple #1
0
        private void boxBlurH_4(int[] source, int[] dest, int w, int h, int r)
        {
            //float iar = 1.0F / (r + r + 1);
            IntegerDivider divider = IntegerDivider.GetDivider(r + r + 1);

            Parallel.For(0, h, _pOptions, i =>
            {
                var ti  = i * w;
                var li  = ti;
                var ri  = ti;
                var fv  = source[ti];
                var lv  = source[ti + w - 1];
                var val = (r + 1) * fv;
                for (var j = 0; j < r; j++)
                {
                    val += source[ri++];
                }
                for (var j = 0; j <= r; j++)
                {
                    val       += source[ri++] - fv;
                    dest[ti++] = divider.Divide(val);
                }
                for (var j = r + 1; j < w - r; j++)
                {
                    val       += source[ri++] - dest[li++];
                    dest[ti++] = divider.Divide(val);
                }
                for (var j = w - r; j < w; j++)
                {
                    val       += lv - source[li++];
                    dest[ti++] = divider.Divide(val);
                }
            });
        }
Exemple #2
0
        private void boxBlurT_4(int[] source, int[] dest, int w, int h, int r)
        {
            //float iar = 1.0F / (r + r + 1);
            IntegerDivider divider = IntegerDivider.GetDivider(r + r + 1);

            Parallel.For(0, w, _pOptions, i =>
            {
                var ti  = i;
                var li  = ti;
                var ri  = ti;
                var fv  = source[ti];
                var lv  = source[ti + w * (h - 1)];
                var val = (r + 1) * fv;;
                for (int j = 0; j < r; j++)
                {
                    val += source[ri];
                    ri  += w;
                }
                for (var j = 0; j <= r; j++)
                {
                    val     += source[ri] - fv;
                    dest[ti] = divider.Divide(val);
                    ri      += w;
                    ti      += w;
                }
                for (var j = r + 1; j < h - r; j++)
                {
                    val     += source[ri] - source[li];
                    dest[ti] = divider.Divide(val);
                    li      += w;
                    ri      += w;
                    ti      += w;
                }
                for (var j = h - r; j < h; j++)
                {
                    val     += lv - source[li];
                    dest[ti] = divider.Divide(val);
                    li      += w;
                    ti      += w;
                }
            });
        }