Esempio n. 1
0
 def test_value(self, input_param, input_data):
     for p in TEST_NDARRAYS:
         cropper = RandScaleCropd(**input_param)
         input_data["img"] = p(input_data["img"])
         result = cropper(input_data)
         roi = [(2 - i // 2, 2 + i - i // 2) for i in cropper._size]
         assert_allclose(result["img"],
                         input_data["img"][:, roi[0][0]:roi[0][1],
                                           roi[1][0]:roi[1][1]],
                         type_test=False)
Esempio n. 2
0
 def test_random_shape(self, input_param, input_data, expected_shape):
     cropper = RandScaleCropd(**input_param)
     cropper.set_random_state(seed=123)
     result = cropper(input_data)
     self.assertTupleEqual(result["img"].shape, expected_shape)
Esempio n. 3
0
 def test_shape(self, input_param, input_data, expected_shape):
     result = RandScaleCropd(**input_param)(input_data)
     self.assertTupleEqual(result["img"].shape, expected_shape)
 def test_value(self, input_param, input_data):
     cropper = RandScaleCropd(**input_param)
     result = cropper(input_data)
     roi = [(2 - i // 2, 2 + i - i // 2) for i in cropper._size]
     np.testing.assert_allclose(result["img"], input_data["img"][:, roi[0][0] : roi[0][1], roi[1][0] : roi[1][1]])