Example #1
0
 def test_scaling_3d(self):
     mask = np.zeros((10, 20, 20), dtype=np.uint8)
     mask[1:-1, 2:-2, 2:-2] = 1
     mask2 = np.copy(mask)
     mask2[2:-2, 4:-4, 4:-4] = 0
     nm_scalar = UNIT_SCALE[Units.nm.value]
     voxel_size = (2 / nm_scalar, 1 / nm_scalar, 1 / nm_scalar)
     result_mask = BorderRim.border_mask(mask, 2, Units.nm, voxel_size)
     assert np.all(result_mask == mask2)
Example #2
0
 def test_base_2d(self):
     mask = np.zeros((6, 6), dtype=np.uint8)
     mask[1:-1, 1:-1] = 1
     nm_scalar = UNIT_SCALE[Units.nm.value]
     voxel_size = (1 / nm_scalar,) * 2
     result_mask = BorderRim.border_mask(mask, 1, Units.nm, voxel_size)
     mask2 = np.copy(mask)
     mask2[2:-2, 2:-2] = 0
     assert np.all(mask2 == result_mask)
Example #3
0
 def test_base_3d(self):
     mask = np.zeros((20, 20, 20), dtype=np.uint8)
     mask[2:-2, 2:-2, 2:-2] = 1
     mask2 = np.copy(mask)
     mask2[3:-3, 3:-3, 3:-3] = 0
     nm_scalar = UNIT_SCALE[Units.nm.value]
     voxel_size = (1 / nm_scalar,) * 3
     result_mask = BorderRim.border_mask(mask, 1, Units.nm, voxel_size)
     assert np.all(result_mask == mask2)