def test_clear_border(): arr = np.array([ [2, 2, 0, 0], [0, 0, 0, 0], [0, 2, 2, 0], [0, 0, 0, 0], ]) plane = Plane(arr) out = plane.clear_border(object_label=2, fill_val=5) assert isinstance(out, Plane) assert np.all(out.image[0, 0:2] == [5, 5]) assert np.all(out.image[2, 1:3] == [2, 2])
def test_to_from_sitk(plane): """Test `SimpleITK` conversion.""" pytest.importorskip('SimpleITK') sitk_image = plane.to_sitk_image() new_plane = Plane.from_sitk_image(sitk_image) assert new_plane == plane
def test_compare_with_digitized(plane): segmented = Plane(plane.image > plane.image.mean()) plane.compare_with_digitized(segmented)
def plane(): data = np.arange(625).reshape(25, 25) return Plane(data)
def test_generate_mesh(plane): """Property test for mesh generation method.""" seg = Plane(1.0 * (plane.image > 5)) mesh = seg.generate_mesh(plot=False) assert isinstance(mesh, TriangleMesh)
def test_le(plane): greater_plane = Plane(plane.image + 1) assert np.all((plane <= greater_plane).image) assert not np.all((greater_plane <= plane).image) assert np.all((plane <= plane).image)
def test_ge(plane): lesser_plane = Plane(plane.image - 1) assert np.all((plane >= lesser_plane).image) assert not np.all((lesser_plane >= plane).image) assert np.all((plane >= plane).image)
def test_compare_with_other(plane): other = Plane(np.ones_like(plane.image)) plane.compare_with_other(other)