Save all colors

This commit is contained in:
Benjamin Loison 2024-05-13 18:22:25 +02:00
parent 36b17eb3cc
commit ac32abede1
No known key found for this signature in database

View File

@ -18,24 +18,26 @@ class Operation(Enum):
OPERATION = Operation.LOAD_RAW
RESOLUTION = 100
print(f'{OPERATION = }')
if OPERATION == Operation.LOAD_NPY:
print(f'{RESOLUTION = }')
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'):
if file.endswith('.NEF') or file.endswith('.ARW'):
#print(file)
imageFilePath = f'{imagesCameraFolder}/{file}'
numpyFilePath = f'{imageFilePath}.npy'
for color in Color:
if OPERATION in [Operation.LOAD_RAW, Operation.SAVE]:
rawColorChannels = {}
if OPERATION in [Operation.LOAD_RAW, Operation.SAVE]:
for color in Color:
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
rawColorChannels[color] = rawColorChannel
if OPERATION == Operation.SAVE:
np.save(numpyFilePath, rawColorChannels)
if OPERATION == Operation.LOAD_NPY:
rawColorChannels = np.load(numpyFilePath, allow_pickle = True)
rawColorChannelsItem = rawColorChannels.item()
for color in Color:
print(color, rawColorChannelsItem[color].mean())