Correct iterativeMean implementation for images

Otherwise get:

```
Traceback (most recent call last):
  File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./extract_noise.py", line 148, in <module>
    treatImage(imageFileName, color = color)
  File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./extract_noise.py", line 114, in treatImage
    estimatedPrnuIterativeMean.add(imageNoiseNpArray)
  File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 34, in add
    self.mean = ((self.mean * self.numberOfElementsInMean) + element) / (self.numberOfElementsInMean + 1)
                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
```
This commit is contained in:
Benjamin Loison 2024-04-27 15:58:29 +02:00
parent bd0b9aca94
commit ee7353cfde
No known key found for this signature in database

View File

@ -31,5 +31,8 @@ class iterativeMean:
numberOfElementsInMean = 0
def add(self, element):
self.mean = ((self.mean * self.numberOfElementsInMean) + element) / (self.numberOfElementsInMean + 1)
self.numberOfElementsInMean += 1
if self.mean is None:
self.mean = element
else:
self.mean = ((self.mean * self.numberOfElementsInMean) + element) / (self.numberOfElementsInMean + 1)
self.numberOfElementsInMean += 1