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]; } } }
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]; } } }
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); }
public BufferField Congruence() { var f = new BufferField(GPU, Width, Height, Channels); return(f); }