diff --git a/datasets/raise/extract_noise.py b/datasets/raise/extract_noise.py index 83c2f77..895488d 100755 --- a/datasets/raise/extract_noise.py +++ b/datasets/raise/extract_noise.py @@ -10,6 +10,7 @@ import csv import rawpy from utils import Color import matplotlib.pyplot as plt +from scipy.ndimage import gaussian_filter imagesFolderPath = 'rafael/arw' imagesFolderPathFileName = imagesFolderPath.replace('/', '_') @@ -100,7 +101,7 @@ def getImageNpArray(imageFileName, computeExtremes, color): maxColor = colorRawImageVisibleMax return - if imageFileName.endswith('.NEF') or imageFileName.endswith('.ARW'): + if (imageFileName.endswith('.NEF') or imageFileName.endswith('.ARW')) and denoiser != 'mean': imageNpArray = (imageNpArray - minColor) / (maxColor - minColor) # Pay attention to range of values expected by the denoiser. # Indeed if provide the thousands valued raw image, then the denoiser only returns values between 0 and 1 and making the difference between both look pointless. @@ -128,7 +129,7 @@ def treatImage(imageFileName, computeExtremes = False, color = None): mean = ((mean * numberOfImagesInMean) + imageNoiseNpArray) / (numberOfImagesInMean + 1) numberOfImagesInMean += 1 -if minColor is None or maxColor is None: +if (minColor is None or maxColor is None) and denoiser != 'mean': # Assuming same intensity scale across color channels. for imageFileName in tqdm(imagesFileNames, 'Computing extremes of images'): for color in colors: @@ -148,8 +149,9 @@ if denoiser == 'mean': for color in colors: colorMean = None numberOfImagesInColorMean = 0 - for imageFileName in tqdm(imagesFileNames, f'Computing mean of {color colored images'): + for imageFileName in tqdm(imagesFileNames, f'Computing mean of {color} colored images'): imageNpArray = getImageNpArray(imageFileName, False, color) + imageNpArray = gaussian_filter(imageNpArray, sigma = 5) if colorMean is None: colorMean = imageNpArray else: