Files
Robust_image_source_identif…/datasets/raise/benchmark_load_part_of_images.py
2024-05-15 16:23:39 +02:00

47 lines
1.6 KiB
Python
Executable File

#!/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()
def __str__(self):
return self.name.lower()
OPERATION = Operation.LOAD_NPY
RESOLUTION = 100
print(f'{OPERATION = }')
if OPERATION == Operation.LOAD_NPY:
print(f'{RESOLUTION = }')
def getNumpyFilePath(imageFilePath, color):
numpyFilePath = f'{imageFilePath}.{color}.npy'
return numpyFilePath
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') or file.endswith('.ARW'):
#print(file)
imageFilePath = f'{imagesCameraFolder}/{file}'
for color in Color:
if OPERATION in [Operation.LOAD_RAW, Operation.SAVE]:
rawColorChannel = getColorChannel(imageFilePath, color)
if OPERATION == Operation.SAVE:
numpyFilePath = getNumpyFilePath(imageFilePath, color)
np.save(numpyFilePath, rawColorChannel)
if OPERATION == Operation.LOAD_NPY:
numpyFilePath = getNumpyFilePath(imageFilePath, color)
rawColorChannel = np.load(numpyFilePath, mmap_mode = 'r')
print(color, rawColorChannel[:RESOLUTION].mean())