Add comments

This commit is contained in:
Benjamin Loison 2024-03-22 12:59:52 +01:00
parent d818714344
commit cf22ff2694
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -18,6 +18,7 @@ NUMBER_OF_IMAGES_PER_PHONE = 100
# Compared to images.
PRNU_FACTOR = 0.1
# Generate PRNUs and images of phones.
# Is such `np.maximum` probabilistically correct with our theoretical method? See #19.
def randomImage(scale):
return np.maximum(np.random.normal(loc = 0, scale = scale, size = (IMAGE_SIZE, IMAGE_SIZE)), 0)
@ -39,8 +40,10 @@ prnus = [toPilImage(prnu) for prnu in prnus]
images = [[toPilImage(image) for image in images[phoneIndex]] for phoneIndex in range(NUMBER_OF_PHONES)]
#images[0][0].show()
# Compute CAI of phone images.
caiImages = [[contextAdaptiveInterpolator(image.load(), image) for image in images[phoneIndex]] for phoneIndex in tqdm(range(NUMBER_OF_PHONES))]
# Guess the phone by consider the one reaching the lowest RMS difference between the estimated PRNU and the actual one.
def getPhoneIndexByNearestPrnu(estimatedPrnu):
nearestPrnuRmsDiff = None
nearestPrnuPhoneIndex = None
@ -51,6 +54,7 @@ def getPhoneIndexByNearestPrnu(estimatedPrnu):
nearestPrnuPhoneIndex = phoneIndex
return nearestPrnuPhoneIndex
# Predict the phones based on the estimated PRNUs and compute each method accuracy.
# 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