From a15b356e16c49fe1939bf776fef383982217ddb2 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Tue, 23 Apr 2024 04:38:40 +0200 Subject: [PATCH] Add and use `getImageNpArray` --- datasets/raise/extract_noise.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/datasets/raise/extract_noise.py b/datasets/raise/extract_noise.py index f99174e..9ff8d12 100755 --- a/datasets/raise/extract_noise.py +++ b/datasets/raise/extract_noise.py @@ -53,9 +53,8 @@ if type_ is not None: minColor = None maxColor = None -# `color` is the actual color to estimate PRNU with. -def treatImage(imageFileName, computeExtremes = False, color = None): - global mean, numberOfImagesInMean, minColor, maxColor +def getImageNpArray(imageFileName, computeExtremes, color): + global minColor, maxColor if raiseNotFlatFields: imageFileName = imageFileName.replace('.png', '.NEF') imageFilePath = f'{imagesFolderPath}/nef/{imageFileName}' @@ -100,7 +99,14 @@ def treatImage(imageFileName, computeExtremes = False, color = None): else: imagePil = Image.open(imageFilePath) imageNpArray = img_as_float(np.array(imagePil)) - # Could make not `.nef` compatible. + return imageNpArray + +# `color` is the actual color to estimate PRNU with. +def treatImage(imageFileName, computeExtremes = False, color = None): + global mean, numberOfImagesInMean + imageNpArray = getImageNpArray(imageFileName, computeExtremes, color) + if imageNpArray is None: + return match denoiser: case 'wavelet': imageDenoisedNpArray = denoise(imageNpArray, rescale_sigma=True)