Benjamin Loison
7af96d6bf6
Verified with: ```py myIterativeMean = iterativeMean() print(myIterativeMean.mean) myIterativeMean.addElement(2) print(myIterativeMean.mean) myIterativeMean.addElement(3) print(myIterativeMean.mean) ``` Note that cannot simplify as follows in the general case of using images as `element`s for instance: ```diff diff --git a/datasets/raise/utils.py b/datasets/raise/utils.py index fba5523..a116edb 100644 --- a/datasets/raise/utils.py +++ b/datasets/raise/utils.py @@ -27,12 +27,9 @@ def denoise(imageNpArray, denoiserName): return imageDenoisedNpArray class iterativeMean(): - mean = None + mean = 0 numberOfElementsInMean = 0 def addElement(self, element): - if self.mean is None: - self.mean = element - else: - self.mean = ((self.mean * self.numberOfElementsInMean) + element) / (self.numberOfElementsInMean + 1) + self.mean = ((self.mean * self.numberOfElementsInMean) + element) / (self.numberOfElementsInMean + 1) self.numberOfElementsInMean += 1 \ No newline at end of file ``` |
||
---|---|---|
.. | ||
fake | ||
noise_free_test_images | ||
rafael/240424 | ||
raise | ||
vision |