Args: factors: factor range to randomly scale by ``v = v * (1 + factor)``. if single number, factor value is picked from (-factors, factors). prob: probability of scale. channel_wise: if True, scale on each channel separately. Please ensur
(
self,
factors: tuple[float, float] | float,
prob: float = 0.1,
channel_wise: bool = False,
dtype: DtypeLike = np.float32,
)
| 684 | backend = ScaleIntensity.backend |
| 685 | |
| 686 | def __init__( |
| 687 | self, |
| 688 | factors: tuple[float, float] | float, |
| 689 | prob: float = 0.1, |
| 690 | channel_wise: bool = False, |
| 691 | dtype: DtypeLike = np.float32, |
| 692 | ) -> None: |
| 693 | """ |
| 694 | Args: |
| 695 | factors: factor range to randomly scale by ``v = v * (1 + factor)``. |
| 696 | if single number, factor value is picked from (-factors, factors). |
| 697 | prob: probability of scale. |
| 698 | channel_wise: if True, scale on each channel separately. Please ensure |
| 699 | that the first dimension represents the channel of the image if True. |
| 700 | dtype: output data type, if None, same as input image. defaults to float32. |
| 701 | |
| 702 | """ |
| 703 | RandomizableTransform.__init__(self, prob) |
| 704 | if isinstance(factors, (int, float)): |
| 705 | self.factors = (min(-factors, factors), max(-factors, factors)) |
| 706 | elif len(factors) != 2: |
| 707 | raise ValueError(f"factors should be a number or pair of numbers, got {factors}.") |
| 708 | else: |
| 709 | self.factors = (min(factors), max(factors)) |
| 710 | self.factor = self.factors[0] |
| 711 | self.channel_wise = channel_wise |
| 712 | self.dtype = dtype |
| 713 | |
| 714 | def randomize(self, data: Any | None = None) -> None: |
| 715 | super().randomize(None) |