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

Method __call__

monai/transforms/intensity/array.py:1017–1036  ·  view source on GitHub ↗

Apply the transform to `img`.

(self, img: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

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
1039class ClipIntensityPercentiles(Transform):

Callers

nothing calls this directly

Calls 4

convert_to_tensorFunction · 0.90
get_track_metaFunction · 0.90
clipFunction · 0.90
convert_data_typeFunction · 0.90

Tested by

no test coverage detected