private CellsAroundPixel GetCellsAroundPixel(int x, int y) { CellsAroundPixel datum = new CellsAroundPixel(); datum.UpLeft = GetCellIndex(x, y, -1, 1); datum.Left = GetCellIndex(x, y, -1, 0); datum.DownLeft = GetCellIndex(x, y, -1, -1); datum.Center = GetCellIndex(x, y, 0, 0); datum.Up = GetCellIndex(x, y, 0, 1); datum.Down = GetCellIndex(x, y, 0, -1); datum.UpRight = GetCellIndex(x, y, 1, 1); datum.Right = GetCellIndex(x, y, 1, 0); datum.DownRight = GetCellIndex(x, y, 1, -1); return(datum); }
private ComputeBuffer GetCellsAroundPixelBuffer() { ComputeBuffer ret = new ComputeBuffer(SourceImageResolution, CellsAroundPixelStride); CellsAroundPixel[] data = new CellsAroundPixel[SourceImageResolution]; for (int x = 0; x < _sourceImageWidth; x++) { for (int y = 0; y < _sourceImageHeight; y++) { CellsAroundPixel datum = GetCellsAroundPixel(x, y); int index = x + y * _sourceImageWidth; data[index] = datum; } } ret.SetData(data); return(ret); }