From a09f2ba1c088c08f2539a7f1068916b817940453 Mon Sep 17 00:00:00 2001 From: Benjamin Loison <12752145+Benjamin-Loison@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:06:05 +0200 Subject: [PATCH] #29: Add `Nikon D7000` 4946x3278 PRNU estimation from NEF to PNG images --- datasets/raise/extract_noise.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/datasets/raise/extract_noise.py b/datasets/raise/extract_noise.py index dd3aba5..6ddc706 100755 --- a/datasets/raise/extract_noise.py +++ b/datasets/raise/extract_noise.py @@ -7,7 +7,7 @@ from PIL import Image import os from tqdm import tqdm -imagesFolderPath = 'flat-field' +imagesFolderPath = 'raise_nef_png' denoiser = 'wavelet' npArrayFilePath = f'mean_{imagesFolderPath}_{denoiser}.npy' @@ -16,7 +16,35 @@ denoise = getattr(skimage.restoration, f'denoise_{denoiser}') mean = None numberOfImagesInMean = 0 +import csv +import magic +import re + +deviceFiles = {} +resolutionFiles = {} +files = {} +resolutionFiles = {} + +with open('RAISE_all.csv') as csvfile: + reader = csv.DictReader(csvfile) + for row in tqdm(list(reader)): + file = row['File'] + '.png' + device = row['Device'] + resolution = row['Image Size'] + deviceFiles[file] = device + #resolutionFiles[file] = resolution + image = Image.open(f'{imagesFolderPath}/{file}') + #t = magic.from_file(f'{imagesFolderPath}/{file}.png') + resolution = image.size + resolutionFiles[file] = resolution#re.search('(\d+) x (\d+)', t).groups() + #print(device, resolution) + #files[f'{file}.png'] = row + imagesFileNames = os.listdir(imagesFolderPath) +#print(len(imagesFileNames)) +# imageFileName.replace('.png', '') +imagesFileNames = [imageFileName for imageFileName in imagesFileNames if deviceFiles[imageFileName] == 'Nikon D7000' and resolutionFiles[imageFileName] == (4946, 3278)] +#print(len(imagesFileNames)) def treatImage(imageFileName): global mean, numberOfImagesInMean