public unsafe void TestAverageIntensityProjection() { const int pixels = 512 * 512; const int subsamples = 11; var rng = new PseudoRandom(0x2DB8498F); var slabData = new ushort[pixels * subsamples]; for (var n = 0; n < slabData.Length; ++n) { slabData[n] = (ushort)rng.Next(ushort.MinValue, ushort.MaxValue); } var expectedResults = new ushort[pixels]; for (var p = 0; p < pixels; ++p) { expectedResults[p] = (ushort)Math.Round(Enumerable.Range(0, subsamples).Select(s => slabData[s * pixels + p]).Average(v => v)); } SlabProjection.ForceCodeJit(); var actualResults = new ushort[pixels]; var projectedData = new byte[pixels * sizeof(ushort)]; fixed(ushort *pSlabData = slabData) { SlabProjection.AggregateSlabAverageIntensity((IntPtr)pSlabData, projectedData, subsamples, pixels, 2, false); Buffer.BlockCopy(projectedData, 0, actualResults, 0, projectedData.Length); } Assert.AreEqual(expectedResults, actualResults); }
public void Initialize() { SlabProjection.ForceCodeJit(); }