Add and use getImageNpArray

This commit is contained in:
Benjamin Loison 2024-04-23 04:38:40 +02:00
parent 809aa7fb43
commit a15b356e16
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -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)