public void TestDistance3DOosterbroek0() { ImageRaster3D <bool> mask = CreateTestMask3D0(); ImageRaster3D <float> distance_true = new ImageRaster3D <float>(mask.Raster); ImageRaster3D <float> distance_test = new ImageRaster3D <float>(mask.Raster); float[] voxel_size = new float[] { 1, 1, 1 }; ToolsDistance.DistanceTransform3DMediumRBA(mask, voxel_size, distance_true); ToolsDistance.DistanceTransform3DOosterbroekRBA(mask, voxel_size, distance_test); for (int index = 0; index < distance_test.ElementCount; index++) { Assert.AreEqual(distance_true[index], distance_test[index]); } }
public void TestDistance3DMedium() { ImageRaster3D <bool> mask = CreateTestMask3D0(); ImageRaster3D <float> distance = new ImageRaster3D <float>(mask.Raster); ToolsDistance.DistanceTransform3DMediumRBA(mask, new float[] { 1.0f, 1.0f, 1.0f }, distance); Assert.AreEqual(0.0f, distance[0]); Assert.AreEqual(1.0f, distance[1]); Assert.AreEqual(ToolsMath.Sqrt(2.0f), distance[2]); Assert.AreEqual(2.0f, distance[3]); Assert.AreEqual(ToolsMath.Sqrt(5.0f), distance[4]); Assert.AreEqual(ToolsMath.Sqrt(8.0f), distance[20]); Assert.AreEqual(ToolsMath.Sqrt(24.0f), distance[120]); Assert.AreEqual(ToolsMath.Sqrt(17.0f), distance[124]); }
public void TestDistance3DOosterbroek1() { ImageRaster3D <bool> mask = CreateTestMask3D1(); ImageRaster3D <float> distance_true = new ImageRaster3D <float>(mask.Raster); ImageRaster3D <float> distance_test = new ImageRaster3D <float>(mask.Raster); float[] voxel_size = new float[] { 0.31f, 0.31f, 1.25f }; ToolsDistance.DistanceTransform3DMediumRBA(mask, voxel_size, distance_true); ToolsDistance.DistanceTransform3DOosterbroekRBA(mask, voxel_size, distance_test); float Tol = 0.1f; for (int index = 0; index < distance_test.ElementCount; index++) { Assert.IsTrue(Math.Abs(distance_true[index] - distance_test[index]) < Tol); } }