From 817c016815ca98b9e4717f09bf719d1f9640fb88 Mon Sep 17 00:00:00 2001 From: Benjamin Loison <12752145+Benjamin-Loison@users.noreply.github.com> Date: Tue, 16 Apr 2024 04:06:49 +0200 Subject: [PATCH] Give a try to get image size with `rawpy` but it seems far slower MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As got: ``` Filtering images: 0%|▏ | 21/8156 [00:11<1:17:28, 1.75it/s] ``` --- datasets/raise/extract_noise.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/datasets/raise/extract_noise.py b/datasets/raise/extract_noise.py index 4e12825..5a51a80 100755 --- a/datasets/raise/extract_noise.py +++ b/datasets/raise/extract_noise.py @@ -9,7 +9,7 @@ from tqdm import tqdm import csv import rawpy -imagesFolderPath = '/mnt/HDD0/raise' +imagesFolderPath = '/mnt/HDD0/raise/nef' imagesFolderPathFileName = imagesFolderPath.replace('/', '_') denoiser = 'wavelet' npArrayFilePath = f'mean_{imagesFolderPathFileName}_{denoiser}.npy' @@ -19,7 +19,9 @@ denoise = getattr(skimage.restoration, f'denoise_{denoiser}') mean = None numberOfImagesInMean = 0 -imagesFileNames = os.listdir(imagesFolderPath + '/png') +imagesFileNames = os.listdir(imagesFolderPath) +#print(rawpy.imread(f'{imagesFolderPath}/{imagesFileNames[0]}').sizes.raw_height) +#exit(1) requiresRaiseFiltering = True if requiresRaiseFiltering: @@ -28,10 +30,10 @@ if requiresRaiseFiltering: with open('RAISE_all.csv') as csvfile: reader = csv.DictReader(csvfile) for row in tqdm(list(reader), 'CSV parsing'): - file = row['File'] + '.png' + file = row['File'] + '.NEF' files[file] = row - 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 = [imageFileName for imageFileName in tqdm(imagesFileNames, 'Filtering images') if files[imageFileName]['Device'] == 'Nikon D7000' and [getattr(rawpy.imread(f'{imagesFolderPath}/{imageFileName}').sizes, dimension) for dimension in ['width', 'height']] == [4992, 3280]] #imagesFileNames = [f'DSC0{imageIndex}.ARW' for imageIndex in range(2807, 2911)] minColor = None