Prefer *mean* over *average*

This commit is contained in:
Benjamin Loison 2024-03-22 12:54:34 +01:00
parent 41926663b7
commit 464e43861b
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -51,10 +51,9 @@ def getPhoneIndexByNearestPrnu(estimatedPrnu):
nearestPrnuPhoneIndex = phoneIndex
return nearestPrnuPhoneIndex
# Should choose between *average* and *mean*, I would prefer *mean*.
# What about CAI on `phoneImagesMean`?
correctGuessesByAverageImages = 0
correctGuessesByAverageCAIImages = 0
# What about CAI on `phoneImagesMean`? See https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/9#issuecomment-1369.
correctGuessesByMeanImages = 0
correctGuessesByMeanCAIImages = 0
for phoneIndex in range(NUMBER_OF_PHONES):
phoneImages = images[phoneIndex]
phoneCaiImages = caiImages[phoneIndex]
@ -62,14 +61,14 @@ for phoneIndex in range(NUMBER_OF_PHONES):
phoneImagesMean = toPilImage(np.array(phoneImages).mean(axis = 0))
caiImagesMean = toPilImage(np.array(phoneCaiImages).mean(axis = 0))
phonePrnu = prnus[phoneIndex]
print('RMS diff with average image =', rmsdiff(phoneImagesMean, phonePrnu))
print('RMS diff with average CAI images =', rmsdiff(caiImagesMean, phonePrnu))
guessedPhoneIndexByAverageImages = getPhoneIndexByNearestPrnu(phoneImagesMean)
guessedPhoneIndexByAverageCAIImages = getPhoneIndexByNearestPrnu(caiImagesMean)
print(f'Actual phone index {phoneIndex}, guessed phone index {guessedPhoneIndexByAverageImages} by averages images and {guessedPhoneIndexByAverageCAIImages} by average CAI images')
correctGuessesByAverageImages += 1 if phoneIndex == guessedPhoneIndexByAverageImages else 0
correctGuessesByAverageCAIImages += 1 if phoneIndex == guessedPhoneIndexByAverageCAIImages else 0
print('RMS diff with mean image =', rmsdiff(phoneImagesMean, phonePrnu))
print('RMS diff with mean CAI images =', rmsdiff(caiImagesMean, phonePrnu))
guessedPhoneIndexByMeanImages = getPhoneIndexByNearestPrnu(phoneImagesMean)
guessedPhoneIndexByMeanCAIImages = getPhoneIndexByNearestPrnu(caiImagesMean)
print(f'Actual phone index {phoneIndex}, guessed phone index {guessedPhoneIndexByMeanImages} by mean images and {guessedPhoneIndexByMeanCAIImages} by mean CAI images')
correctGuessesByMeanImages += 1 if phoneIndex == guessedPhoneIndexByMeanImages else 0
correctGuessesByMeanCAIImages += 1 if phoneIndex == guessedPhoneIndexByMeanCAIImages else 0
print(f'{correctGuessesByAverageImages / NUMBER_OF_PHONES=}')
print(f'{correctGuessesByAverageCAIImages / NUMBER_OF_PHONES=}')
print(f'{correctGuessesByMeanImages / NUMBER_OF_PHONES=}')
print(f'{correctGuessesByMeanCAIImages / NUMBER_OF_PHONES=}')