MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/transforms/intensity/array.py:1272–1298  ·  view source on GitHub ↗
(
        self,
        prob: float = 0.1,
        gamma: Sequence[float] | float = (0.5, 4.5),
        invert_image: bool = False,
        retain_stats: bool = False,
    )

Source from the content-addressed store, hash-verified

1270 backend = AdjustContrast.backend
1271
1272 def __init__(
1273 self,
1274 prob: float = 0.1,
1275 gamma: Sequence[float] | float = (0.5, 4.5),
1276 invert_image: bool = False,
1277 retain_stats: bool = False,
1278 ) -> None:
1279 RandomizableTransform.__init__(self, prob)
1280
1281 if isinstance(gamma, (int, float)):
1282 if gamma <= 0.5:
1283 raise ValueError(
1284 f"if gamma is a number, must greater than 0.5 and value is picked from (0.5, gamma), got {gamma}"
1285 )
1286 self.gamma = (0.5, gamma)
1287 elif len(gamma) != 2:
1288 raise ValueError("gamma should be a number or pair of numbers.")
1289 else:
1290 self.gamma = (min(gamma), max(gamma))
1291
1292 self.gamma_value: float = 1.0
1293 self.invert_image: bool = invert_image
1294 self.retain_stats: bool = retain_stats
1295
1296 self.adjust_contrast = AdjustContrast(
1297 self.gamma_value, invert_image=self.invert_image, retain_stats=self.retain_stats
1298 )
1299
1300 def randomize(self, data: Any | None = None) -> None:
1301 super().randomize(None)

Callers

nothing calls this directly

Calls 4

minFunction · 0.85
maxFunction · 0.85
AdjustContrastClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected