Try making not flat-images compatible

This commit is contained in:
Benjamin Loison 2024-04-16 03:59:26 +02:00
parent 3a4f774e28
commit 04e0de4d33
No known key found for this signature in database

View File

@ -9,7 +9,7 @@ from tqdm import tqdm
import csv
import rawpy
imagesFolderPath = 'flat-field/nef'
imagesFolderPath = '/mnt/HDD0/raise'
imagesFolderPathFileName = imagesFolderPath.replace('/', '_')
denoiser = 'wavelet'
npArrayFilePath = f'mean_{imagesFolderPathFileName}_{denoiser}.npy'
@ -19,9 +19,9 @@ denoise = getattr(skimage.restoration, f'denoise_{denoiser}')
mean = None
numberOfImagesInMean = 0
imagesFileNames = os.listdir(imagesFolderPath)
imagesFileNames = os.listdir(imagesFolderPath + '/png')
requiresRaiseFiltering = False
requiresRaiseFiltering = True
if requiresRaiseFiltering:
files = {}
@ -31,15 +31,16 @@ if requiresRaiseFiltering:
file = row['File'] + '.png'
files[file] = row
imagesFileNames = [imageFileName for imageFileName in tqdm(imagesFileNames, 'Filtering images') if files[imageFileName]['Device'] == 'Nikon D7000' and Image.open(f'{imagesFolderPath}/{imageFileName}').size == (4946, 3278)]
imagesFileNames = [imageFileName for imageFileName in tqdm(imagesFileNames, 'Filtering images') if files[imageFileName]['Device'] == 'Nikon D7000' and Image.open(f'{imagesFolderPath}/png/{imageFileName}').size == (4946, 3278)]
#imagesFileNames = [f'DSC0{imageIndex}.ARW' for imageIndex in range(2807, 2911)]
minColor = None
maxColor = None
def treatImage(imageFileName, computeExtremes = False):
global mean, numberOfImagesInMean, minColor, maxColor
imageFilePath = f'{imagesFolderPath}/{imageFileName}'
if imageFileName.endswith('.NEF'):
imageFilePath = f'{imagesFolderPath}/nef/{imageFileName}'
if imageFileName.endswith('.NEF') or imageFileName.endswith('.ARW'):
with rawpy.imread(imageFilePath) as raw:
colorDesc = raw.color_desc.decode('ascii')
assert colorDesc == 'RGBG'
@ -78,6 +79,9 @@ def treatImage(imageFileName, computeExtremes = False):
for imageFileName in tqdm(imagesFileNames, 'Computing extremes of images'):
treatImage(imageFileName, computeExtremes = True)
print(f'{minColor=}')
print(f'{maxColor=}')
for imageFileName in tqdm(imagesFileNames, 'Denoising images'):
treatImage(imageFileName)