Compare commits

...

1 Commits

Author SHA1 Message Date
ccb2b4bd86
#21: Write PRNU as such to make figures clearer 2024-03-26 03:15:34 +01:00

View File

@ -25,7 +25,7 @@ def randomImage(scale):
imagesWithoutPrnu = [[randomImage(scale = 1) for _ in range(NUMBER_OF_IMAGES_PER_PHONE)] for phoneIndex in range(NUMBER_OF_PHONES)]
prnus = [randomImage(scale = PRNU_FACTOR) for _ in range(NUMBER_OF_PHONES)]
prnus = [np.array(Image.open('prnu.png').convert('F')) * PRNU_FACTOR / 255]
imagesWithPrnu = [[imageWithoutPrnu + prnus[phoneIndex] for imageWithoutPrnu in imagesWithoutPrnu[phoneIndex]] for phoneIndex in range(NUMBER_OF_PHONES)]
@ -75,6 +75,23 @@ plt.show()
##
def toFileName(title):
return title.lower().replace(' ', '_').replace(',', '_')
for title, image in zip(['Actual PRNU', 'First image without PRNU'], [prnus[0], imagesWithoutPrnu[0][0]]):
plt.title(title)
plt.imshow(image)
plt.savefig(title.lower().replace(' ', '_') + '.svg')
for numberOfImages in [10 ** power for power in range(NUMBER_OF_ROWS)]:
title = 'First image with PRNU' if numberOfImages == 1 else f'Mean of first {numberOfImages:,} images with PRNU'
image = np.array(imagesWithPrnu[0][:numberOfImages]).mean(axis = 0)
plt.title(f'{title}\ni.e. estimated PRNU\nRMS with actual PRNU = {round(rmsDiffNumpy(image, prnus[0]), 4)}')
plt.imshow(image)
plt.savefig(f'{toFileName(title)}.svg')
##
# Compute CAI of phone images.
caiImages = [[contextAdaptiveInterpolator(image.load(), image) for image in imagesWithPrnuPil[phoneIndex]] for phoneIndex in tqdm(range(NUMBER_OF_PHONES))]
#caiImages[0][0].show()