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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user