public void TestDistance1D() { ImageRaster3D <bool> mask = new ImageRaster3D <bool>(5, 1, 1); mask[0] = true; mask[3] = true; ImageRaster3D <float> distance = ToolsDistance.DistanceTransform3D(mask, new float[] { 1.5f, 1.5f, 1.5f }); Assert.AreEqual(0.0f, distance[0]); Assert.AreEqual(1.5f, distance[1]); Assert.AreEqual(1.5f, distance[2]); Assert.AreEqual(0.0f, distance[3]); Assert.AreEqual(1.5f, distance[4]); }
public void TestDistance2D() { ImageRaster3D <bool> mask = new ImageRaster3D <bool>(5, 5, 1); mask[0] = true; mask[6] = true; mask[12] = true; mask[13] = true; mask[19] = true; ImageRaster3D <float> distance = ToolsDistance.DistanceTransform3D(mask, new float[] { 1.0f, 1.0f, 1.0f }); 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]); }