From 115bab4b4cc487c2e5e14b66ae3c5308ab538957 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Wed, 5 Jun 2024 16:47:24 +0200 Subject: [PATCH] Add and use `getEstimatedPrnu` --- datasets/raise/fft/verify_dots.py | 43 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/datasets/raise/fft/verify_dots.py b/datasets/raise/fft/verify_dots.py index af744ac..bb4c40a 100644 --- a/datasets/raise/fft/verify_dots.py +++ b/datasets/raise/fft/verify_dots.py @@ -8,30 +8,33 @@ sys.path.insert(0, '../') from utils import isARawImage, Color, getColorChannel, mergeSingleColorChannelImagesAccordingToBayerFilter, iterativeMean -folder = '../rafael/230424' -meanImages = iterativeMean() -filePaths = [f'{folder}/{file}' for file in os.listdir(folder) if isARawImage(file)] +FOLDERS = { + 'Rafael 23/04/24': '../rafael/230424', + 'RAISE flat-field': '../flat-field/nef', + 'RAISE not flat-field': '../not_flat-field/nef', +} -for filePath in tqdm(filePaths, 'Compute mean image'): +def getImageMergedColorChannels(filePath): imageColorChannels = {color: getColorChannel(filePath, color) for color in Color} imageMergedColorChannels = mergeSingleColorChannelImagesAccordingToBayerFilter(imageColorChannels) - meanImages.add(imageMergedColorChannels) - #plt.imshow(imageMergedColorChannels) - #plt.show() - #break + return imageMergedColorChannels -#plt.imshow(meanImages.mean) -#plt.show() +def getEstimatedPrnu(folder): + meanImages = iterativeMean() + filePaths = [f'{folder}/{file}' for file in os.listdir(folder) if isARawImage(file)] -# Is not there anything clever than this to do? See [Robust_image_source_identification_on_modern_smartphones/issues/72](https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/72). -estimatedPrnu = iterativeMean() -for filePath in tqdm(filePaths, 'Compute estimated PRNU'): - imageColorChannels = {color: getColorChannel(filePath, color) for color in Color} - imageMergedColorChannels = mergeSingleColorChannelImagesAccordingToBayerFilter(imageColorChannels) - estimatedPrnu.add(imageMergedColorChannels - meanImages.mean) - #plt.imshow(estimatedPrnu.mean) - #plt.show() - #break + for filePath in tqdm(filePaths, 'Compute mean image'): + imageMergedColorChannels = getImageMergedColorChannels(filePath) + meanImages.add(imageMergedColorChannels) -plt.imshow(estimatedPrnu.mean) + # Is not there anything clever than this to do? See [Robust_image_source_identification_on_modern_smartphones/issues/72](https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/72). + estimatedPrnu = iterativeMean() + for filePath in tqdm(filePaths, 'Compute estimated PRNU'): + imageMergedColorChannels = getImageMergedColorChannels(filePath) + estimatedPrnu.add(imageMergedColorChannels - meanImages.mean) + return estimatedPrnu.mean + +estimatedPrnu = getEstimatedPrnu(FOLDERS['Rafael 23/04/24']) + +plt.imshow(estimatedPrnu) plt.show() \ No newline at end of file