From 20fcb247c6cdef191c6fc627120d2f3cf4db9aab Mon Sep 17 00:00:00 2001 From: Benjamin Loison <12752145+Benjamin-Loison@users.noreply.github.com> Date: Tue, 30 Apr 2024 03:36:04 +0200 Subject: [PATCH] Simplify loops The idea was initially in the context of #62 to optimize execution speed. --- datasets/raise/split_and_compare_prnus_of_subgroups.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/datasets/raise/split_and_compare_prnus_of_subgroups.py b/datasets/raise/split_and_compare_prnus_of_subgroups.py index 5e385bb..a44021f 100755 --- a/datasets/raise/split_and_compare_prnus_of_subgroups.py +++ b/datasets/raise/split_and_compare_prnus_of_subgroups.py @@ -30,14 +30,15 @@ rmss = [] minColor = None maxColor = None +returnSingleColorChannelImage = lambda singleColorChannelImage, _minColor, _maxColor: singleColorChannelImage + for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else []) + [False], 'Compute extremes'): + rescaleIfNeeded = returnSingleColorChannelImage if computeExtremes else rescaleRawImageForDenoiser for subgroupImageIndex in tqdm(range(numberOfImagesPerSubgroup), 'Subgroup image index'): for subgroupIndex in tqdm(range(NUMBER_OF_SUBGROUPS), 'Subgroup'): imageIndex = (subgroupIndex * NUMBER_OF_SUBGROUPS) + subgroupImageIndex imageFileName = imagesFileNames[imageIndex] imageFilePath = f'{IMAGES_FOLDER}/{imageFileName}' - returnSingleColorChannelImage = lambda singleColorChannelImage, _minColor, _maxColor: singleColorChannelImage - rescaleIfNeeded = returnSingleColorChannelImage if computeExtremes else rescaleRawImageForDenoiser singleColorChannelImages = {color: rescaleIfNeeded(getColorChannel(imageFilePath, color), minColor, maxColor) for color in Color} multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)