Apply the transform to `img`. Raises: ValueError: When ``self.minv=None`` or ``self.maxv=None`` and ``self.factor=None``. Incompatible values.
(self, img: NdarrayOrTensor)
| 475 | self.dtype = dtype |
| 476 | |
| 477 | def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: |
| 478 | """ |
| 479 | Apply the transform to `img`. |
| 480 | |
| 481 | Raises: |
| 482 | ValueError: When ``self.minv=None`` or ``self.maxv=None`` and ``self.factor=None``. Incompatible values. |
| 483 | |
| 484 | """ |
| 485 | img = convert_to_tensor(img, track_meta=get_track_meta()) |
| 486 | img_t = convert_to_tensor(img, track_meta=False) |
| 487 | ret: NdarrayOrTensor |
| 488 | if self.minv is not None or self.maxv is not None: |
| 489 | if self.channel_wise: |
| 490 | out = [rescale_array(d, self.minv, self.maxv, dtype=self.dtype) for d in img_t] |
| 491 | ret = torch.stack(out) # type: ignore |
| 492 | else: |
| 493 | ret = rescale_array(img_t, self.minv, self.maxv, dtype=self.dtype) |
| 494 | else: |
| 495 | ret = (img_t * (1 + self.factor)) if self.factor is not None else img_t |
| 496 | ret = convert_to_dst_type(ret, dst=img, dtype=self.dtype or img_t.dtype)[0] |
| 497 | return ret |
| 498 | |
| 499 | |
| 500 | class ScaleIntensityFixedMean(Transform): |
nothing calls this directly
no test coverage detected