Esempio n. 1
0
        public void DifferenceOf(BufferField inf, ref BufferField otf)
        {
            int area   = Area;
            int width  = Width;
            int height = Height;
            var sb     = Buffer;
            var rb     = inf.Buffer;
            var ob     = otf.Buffer;

            if (GPU != null)
            {
                GPU.For(0, Length, n =>
                {
                    int c       = (int)(n / area);
                    int i       = n - c * area;
                    int y       = (int)(i / width);
                    int x       = i - y * width;
                    ob[c][x, y] = sb[c][x, y] - rb[c][x, y];
                });
            }
            else
            {
                for (int n = 0; n < Length; n++)
                {
                    int c = (int)(n / area);
                    int i = n - c * area;
                    int y = (int)(i / width);
                    int x = i - y * width;
                    ob[c][x, y] = sb[c][x, y] - rb[c][x, y];
                }
            }
        }
Esempio n. 2
0
        public void CopyTo(BufferField frame)
        {
            int area    = Area;
            int width   = Width;
            int height  = Height;
            var sbuffer = Buffer;
            var dbuffer = frame.Buffer;

            if (GPU != null)
            {
                GPU.For(0, Length, n =>
                {
                    int c            = (int)(n / area);
                    int i            = n - c * area;
                    int y            = (int)(i / width);
                    int x            = i - y * width;
                    dbuffer[c][x, y] = sbuffer[c][x, y];
                });
            }
            else
            {
                for (int n = 0; n < Length; n++)
                {
                    int c = (int)(n / area);
                    int i = n - c * area;
                    int y = (int)(i / width);
                    int x = i - y * width;
                    dbuffer[c][x, y] = sbuffer[c][x, y];
                }
            }
        }
Esempio n. 3
0
        public double Loss(BufferField target)
        {
            int area   = Area;
            int width  = Width;
            int height = Height;
            var sb     = Buffer;
            var tb     = target.Buffer;
            var diff   = new double[Length];

            if (GPU != null)
            {
                GPU.For(0, Length, n =>
                {
                    int c   = (int)(n / area);
                    int i   = n - c * area;
                    int y   = (int)(i / width);
                    int x   = i - y * width;
                    diff[n] = DeviceFunction.Abs(sb[c][x, y] - tb[c][x, y]);
                });
            }
            return(diff.Sum() / Area);
        }
Esempio n. 4
0
        public BufferField Congruence()
        {
            var f = new BufferField(GPU, Width, Height, Channels);

            return(f);
        }