Add Gaussian filter to blur images when using mean as denoiser
See https://docs.scipy.org/doc/scipy-1.13.0/reference/generated/scipy.ndimage.gaussian_filter.html#ba1e4df0-d4be-47c2-81e5-059286837a2b.
This commit is contained in:
parent
9641641b61
commit
3ffcd33efe
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user