#31: Establish expected wanted results about finding an identical PRNU for both subgroups

This commit is contained in:
Benjamin Loison 2024-04-02 21:05:15 +02:00
parent f09665f856
commit 631ed6de34
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -9,6 +9,10 @@ sys.path.insert(0, '../../algorithms/image_utils/')
from image_utils import showImageWithMatplotlib
sys.path.insert(0, '../../algorithms/distance/')
from rms_diff import rmsDiffNumpy
NUMBER_OF_SUBGROUPS = 2
fig, axes = plt.subplots(NUMBER_OF_SUBGROUPS, 1)
fig.suptitle(f'PRNU estimation and comparison for {NUMBER_OF_SUBGROUPS} subgroups with different number of flat-images')
@ -17,7 +21,10 @@ IMAGES_FOLDER = 'flat-field/TIF'
imagesFileNames = os.listdir(IMAGES_FOLDER)
numberOfImagesPerSubgroup = len(imagesFileNames) // NUMBER_OF_SUBGROUPS
numberOfImagesThresholds = [1, 5, 50]
# Assume random image order to not introduce a bias.
subgroupsPrnuEstimatesNpArray = []
for subgroupIndex in range(NUMBER_OF_SUBGROUPS):
axis = axes[subgroupIndex]
imagesPrnuEstimateNpArray = []
@ -27,8 +34,19 @@ for subgroupIndex in range(NUMBER_OF_SUBGROUPS):
imageNpArray = np.array(imagePil)
imagePrnuEstimateNpArray = imageNpArray - denoise_tv_chambolle(imageNpArray, weight=0.2, channel_axis=-1)
imagesPrnuEstimateNpArray += [imagePrnuEstimateNpArray]
cameraPrnuEstimateNpArray = np.array(imagesPrnuEstimateNpArray).mean(axis = 0)
axis.set_title(f'PRNU estimate for subgroup {subgroupIndex} with ')
axis.imshow(cameraPrnuEstimateNpArray)
plt.show()
subgroupPrnuEstimateNpArray = []
for numberOfImagesIndex, numberOfImages in enumerate(numberOfImagesThresholds):
subgroupPrnuEstimateNpArray += [np.array(imagesPrnuEstimateNpArray[:numberOfImages]).mean(axis = 0)]
subgroupsPrnuEstimatesNpArray += [subgroupPrnuEstimateNpArray]
'''
axis[numberOfImagesIndex].set_title(f'PRNU estimate for subgroup {subgroupIndex} with ')
axis[numberOfImagesIndex].imshow(cameraPrnuEstimateNpArray)
'''
for numberOfImagesIndex, numberOfImages in enumerate(numberOfImagesThresholds):
rms = rmsDiffNumpy(subgroupsPrnuEstimatesNpArray[0][numberOfImagesIndex], subgroupsPrnuEstimatesNpArray[1][numberOfImagesIndex])
print(numberOfImages, round(rms, 4))
#plt.show()