def test_eval_sliver_distance_two_points(self): """ Two points 2 by 2 pixels diagonal. """ vol1 = np.zeros([20, 21, 22], dtype=np.int8) vol1[10, 10, 10] = 1 vol2 = np.zeros([20, 21, 22], dtype=np.int8) vol2[10, 12, 12] = 1 eval1 = ve.distance_matrics(vol1, vol2, [1, 1, 1]) self.assertAlmostEquals(eval1[2], np.sqrt(2) * 2)
def test_eval_sliver_distance_two_points_with_half_voxelsize(self): """ Two points 2 by 2 pixels diagonal and voxelsize is 0.5 """ vol1 = np.zeros([20, 21, 22], dtype=np.int8) vol1[10, 10, 10] = 1 vol2 = np.zeros([20, 21, 22], dtype=np.int8) vol2[10, 12, 12] = 1 eval1 = ve.distance_matrics(vol1, vol2, [0.5, 0.5, 0.5]) self.assertAlmostEquals(eval1[2], np.sqrt(2))
def test_eval_sliver_distance_for_two_pixels_bigger_volume(self): """ maxd is measured in corner. It is space diagonal of 2 pixels cube. """ vol1 = np.zeros([20, 21, 22], dtype=np.int8) vol1[10:15, 10:15, 10:15] = 1 vol2 = np.zeros([20, 21, 22], dtype=np.int8) vol2[8:17, 8:17, 8:17] = 1 eval1 = ve.distance_matrics(vol1, vol2, [1, 1, 1]) self.assertAlmostEquals(eval1[2], 3 ** (0.5) * 2)
def test_compare_eval_sliver_distance(self): """ comparison of two methods for surface distance computation Second implementation is obsolete """ vol1 = np.zeros([20, 21, 22], dtype=np.int8) vol1[10:15, 10:15, 10:15] = 1 vol2 = np.zeros([20, 21, 22], dtype=np.int8) vol2[8:17, 8:17, 8:17] = 1 eval1 = ve.distance_matrics(vol1, vol2, [1, 1, 1]) self.assertAlmostEquals(eval1[2], 3 ** (0.5) * 2)
def test_eval_sliver_distance_two_points_non_comutative(self): """ Two volumes - obj1 1px and obj2 2px There is different maximal distance from first to second then from second to first """ vol1 = np.zeros([20, 21, 22], dtype=np.int8) vol1[10, 10, 10] = 1 vol2 = np.zeros([20, 21, 22], dtype=np.int8) vol2[10, 12, 10] = 1 vol2[10, 14, 10] = 1 eval1 = ve.distance_matrics(vol1, vol2, [1, 1, 1]) self.assertLess(eval1[0], 4) self.assertGreater(eval1[0], 2)