Add iterativeMean to utils

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
```
This commit is contained in:
Benjamin Loison 2024-04-26 14:16:35 +02:00
parent 7684e1408d
commit 7af96d6bf6
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -24,4 +24,12 @@ def denoise(imageNpArray, denoiserName):
imageDenoisedNpArray = skImageRestorationDenoise(imageNpArray, sigma_color=0.05, sigma_spatial=15)
case 'tv_chambolle':
imageDenoisedNpArray = skImageRestorationDenoise(imageNpArray, weight=0.2)
return imageDenoisedNpArray
return imageDenoisedNpArray
class iterativeMean():
mean = 0
numberOfElementsInMean = 0
def addElement(self, element):
self.mean = ((self.mean * self.numberOfElementsInMean) + element) / (self.numberOfElementsInMean + 1)
self.numberOfElementsInMean += 1