From 36b17eb3cc94b3ed7d04257d7a31d5b64612e7b9 Mon Sep 17 00:00:00 2001 From: Benjamin Loison <12752145+Benjamin-Loison@users.noreply.github.com> Date: Mon, 13 May 2024 17:52:49 +0200 Subject: [PATCH] #62: Add `benchmark_load_part_of_images.py` --- .../raise/benchmark_load_part_of_images.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 datasets/raise/benchmark_load_part_of_images.py diff --git a/datasets/raise/benchmark_load_part_of_images.py b/datasets/raise/benchmark_load_part_of_images.py new file mode 100755 index 0000000..5105afa --- /dev/null +++ b/datasets/raise/benchmark_load_part_of_images.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +from utils import getColorChannel, Color +import os +from tqdm import tqdm +import numpy as np +from enum import Enum, auto + +IMAGES_CAMERAS_FOLDER = { + 'RAISE': 'flat-field/nef', + 'Rafael 23/04/24': 'rafael/230424', +} + +class Operation(Enum): + LOAD_RAW = auto() + SAVE = auto() + LOAD_NPY = auto() + +OPERATION = Operation.LOAD_RAW +RESOLUTION = 100 + +for camera in tqdm(IMAGES_CAMERAS_FOLDER, 'Camera'): + imagesCameraFolder = IMAGES_CAMERAS_FOLDER[camera] + for file in tqdm(os.listdir(imagesCameraFolder), 'Image'): + if file.endswith('.NEF'): + #print(file) + imageFilePath = f'{imagesCameraFolder}/{file}' + numpyFilePath = f'{imageFilePath}.npy' + for color in Color: + if OPERATION in [Operation.LOAD_RAW, Operation.SAVE]: + rawColorChannel = getColorChannel(imageFilePath, color) + if OPERATION == Operation.SAVE: + np.save(numpyFilePath, {color: rawColorChannel}) + if OPERATION == Operation.LOAD_NPY: + rawColorChannel = np.load(numpyFilePath, allow_pickle = True) + #print(type(rawColorChannel)) + #print(rawColorChannel) + #print(rawColorChannel.shape) + print(rawColorChannel.item()[color].mean()) + break + break \ No newline at end of file