Apply the transform to `img`.
(self, img: NdarrayOrTensor, randomize: bool = True)
| 812 | self._coeff = self.R.uniform(*self.coeff_range, n_coeff).tolist() |
| 813 | |
| 814 | def __call__(self, img: NdarrayOrTensor, randomize: bool = True) -> NdarrayOrTensor: |
| 815 | """ |
| 816 | Apply the transform to `img`. |
| 817 | """ |
| 818 | img = convert_to_tensor(img, track_meta=get_track_meta()) |
| 819 | if randomize: |
| 820 | self.randomize(img_size=img.shape[1:]) |
| 821 | |
| 822 | if not self._do_transform: |
| 823 | return img |
| 824 | |
| 825 | num_channels, *spatial_shape = img.shape |
| 826 | _bias_fields = np.stack( |
| 827 | [ |
| 828 | self._generate_random_field(spatial_shape=spatial_shape, degree=self.degree, coeff=self._coeff) |
| 829 | for _ in range(num_channels) |
| 830 | ], |
| 831 | axis=0, |
| 832 | ) |
| 833 | img_np, *_ = convert_data_type(img, np.ndarray) |
| 834 | out: NdarrayOrTensor = img_np * np.exp(_bias_fields) |
| 835 | out, *_ = convert_to_dst_type(src=out, dst=img, dtype=self.dtype or img.dtype) |
| 836 | return out |
| 837 | |
| 838 | |
| 839 | class NormalizeIntensity(Transform): |
nothing calls this directly
no test coverage detected