Apply the transform to `img`.
(self, img: NdarrayOrTensor)
| 1015 | self.dtype = dtype |
| 1016 | |
| 1017 | def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: |
| 1018 | """ |
| 1019 | Apply the transform to `img`. |
| 1020 | """ |
| 1021 | img = convert_to_tensor(img, track_meta=get_track_meta()) |
| 1022 | dtype = self.dtype or img.dtype |
| 1023 | if self.a_max - self.a_min == 0.0: |
| 1024 | warn("Divide by zero (a_min == a_max)", Warning) |
| 1025 | if self.b_min is None: |
| 1026 | return img - self.a_min |
| 1027 | return img - self.a_min + self.b_min |
| 1028 | |
| 1029 | img = (img - self.a_min) / (self.a_max - self.a_min) |
| 1030 | if (self.b_min is not None) and (self.b_max is not None): |
| 1031 | img = img * (self.b_max - self.b_min) + self.b_min |
| 1032 | if self.clip: |
| 1033 | img = clip(img, self.b_min, self.b_max) |
| 1034 | ret: NdarrayOrTensor = convert_data_type(img, dtype=dtype)[0] |
| 1035 | |
| 1036 | return ret |
| 1037 | |
| 1038 | |
| 1039 | class ClipIntensityPercentiles(Transform): |
nothing calls this directly
no test coverage detected