#62: Add benchmark_load_part_of_images.py

This commit is contained in:
Benjamin Loison 2024-05-13 17:52:49 +02:00
parent fb0f78e069
commit 36b17eb3cc
No known key found for this signature in database

View File

@ -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