@@ -20,19 +20,17 @@ class Normalizer:
20
20
normalization_stats : dict, optional
21
21
If provided, then used to get statistics for normalization.
22
22
Otherwise, compute them from a given array.
23
- inplace : bool
24
- Whether to apply operation inplace or return a new array.
25
23
"""
26
24
27
25
def __init__ (self , mode = 'meanstd' , clip_to_quantiles = False , q = (0.01 , 0.99 ),
28
- normalization_stats = None , inplace = False ):
26
+ normalization_stats = None ):
29
27
self .mode = mode
30
28
self .clip_to_quantiles = clip_to_quantiles
31
29
self .q = q
32
30
self .normalization_stats = normalization_stats
33
- self .inplace = inplace
34
31
35
- def normalize (self , array , normalization_stats = None , mode = None , return_stats = False ):
32
+ def normalize (self , array , normalization_stats = None , mode = None , return_stats = False , inplace = False ,
33
+ clip_to_quantiles = None ):
36
34
""" Normalize image with provided stats.
37
35
38
36
Parameters
@@ -45,14 +43,16 @@ def normalize(self, array, normalization_stats=None, mode=None, return_stats=Fal
45
43
If self.normalization_stats is also None, then statistics will by computed by array.
46
44
return_stats : bool, optional
47
45
Whether to return stats used for normalization, by default False
46
+ inplace : bool
47
+ Whether to apply operation inplace or return a new array.
48
48
49
49
Returns
50
50
-------
51
51
numpy.ndarray or (numpy.ndarray, dict)
52
52
"""
53
- clip_to_quantiles = self .clip_to_quantiles
53
+ clip_to_quantiles = self .clip_to_quantiles if clip_to_quantiles is None else clip_to_quantiles
54
54
mode = self .mode if mode is None else mode
55
- array = array if self . inplace else array .copy ()
55
+ array = array if inplace else array .copy ()
56
56
57
57
normalization_stats = normalization_stats if normalization_stats is not None else self .normalization_stats
58
58
@@ -101,7 +101,7 @@ def normalize(self, array, normalization_stats=None, mode=None, return_stats=Fal
101
101
102
102
__call__ = normalize
103
103
104
- def denormalize (self , array , normalization_stats = None , mode = None ):
104
+ def denormalize (self , array , normalization_stats = None , mode = None , inplace = False ):
105
105
""" Denormalize image with provided stats.
106
106
107
107
Parameters
@@ -118,7 +118,7 @@ def denormalize(self, array, normalization_stats=None, mode=None):
118
118
-------
119
119
numpy.ndarray or (numpy.ndarray, dict)
120
120
"""
121
- array = array if self . inplace else array .copy ()
121
+ array = array if inplace else array .copy ()
122
122
mode = self .mode if mode is None else mode
123
123
124
124
if self .normalization_stats is not None :
0 commit comments