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)