Compare commits

...

4 Commits

Author SHA1 Message Date
Benjamin Loison
a6ef3977dd
Add comment concerning printing {min,max}Color 2024-04-16 16:48:29 +02:00
Benjamin Loison
8ca1972ddb
Correct raise not flat-fields processing 2024-04-16 16:48:00 +02:00
Benjamin Loison
817c016815
Give a try to get image size with rawpy but it seems far slower
As got:

```
Filtering images:   0%|▏                                                                               | 21/8156 [00:11<1:17:28,  1.75it/s]
```
2024-04-16 04:06:49 +02:00
Benjamin Loison
04e0de4d33
Try making not flat-images compatible 2024-04-16 03:59:26 +02:00

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,17 @@ 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'):
imageFileName = imageFileName.replace('.png', '.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 +80,11 @@ def treatImage(imageFileName, computeExtremes = False):
for imageFileName in tqdm(imagesFileNames, 'Computing extremes of images'):
treatImage(imageFileName, computeExtremes = True)
# To skip this step next time.
# Maybe thanks to `rawpy.RawPy` fields, possibly stating device maximal value, can avoid doing so to some extent.
print(f'{minColor=}')
print(f'{maxColor=}')
for imageFileName in tqdm(imagesFileNames, 'Denoising images'):
treatImage(imageFileName)