Add and use getImageCrop

This commit is contained in:
Benjamin Loison
2024-05-03 03:13:38 +02:00
parent fd6a9868fe
commit 0c429aa4d6
2 changed files with 10 additions and 5 deletions

View File

@@ -132,12 +132,14 @@ def updateExtremes(imageNpArray, minColor, maxColor):
def print(*toPrint):
__builtin__.print(datetime.now(), *toPrint)
def getColorMeans(imagesFileNames, colors, denoiser):
def getColorMeans(imagesFileNames, colors, denoiser, singleColorChannelCropResolution = None):
colorMeans = {}
for color in colors:
colorIterativeMean = iterativeMean()
for imageFileName in tqdm(imagesFileNames, f'Computing mean of {color} colored images'):
imageNpArray = getImageNpArray(imageFileName, False, color, denoiser)
if singleColorChannelCropResolution is not None:
imageNpArray = getImageCrop(imageNpArray, singleColorChannelCropResolution)
imageNpArray = gaussian_filter(imageNpArray, sigma = 5)
colorIterativeMean.add(imageNpArray)
colorMeans[color] = colorIterativeMean.mean
@@ -156,3 +158,7 @@ def getImageNpArray(imageFilePath, computeExtremes, color, denoiser):
# 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.
return imageNpArray
def getImageCrop(image, cropResolution):
imageCrop = image[:cropResolution[0], :cropResolution[1]]
return imageCrop