WIP: Add .nef
support
This commit is contained in:
parent
a0b366e98a
commit
120eaf563f
@ -7,10 +7,12 @@ from PIL import Image
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
import csv
|
||||
import rawpy
|
||||
|
||||
imagesFolderPath = 'raise_nef_png'
|
||||
imagesFolderPath = 'flat-field/nef'
|
||||
imagesFolderPathFileName = imagesFolderPath.replace('/', '_')
|
||||
denoiser = 'wavelet'
|
||||
npArrayFilePath = f'mean_{imagesFolderPath}_{denoiser}.npy'
|
||||
npArrayFilePath = f'mean_{imagesFolderPathFileName}_{denoiser}.npy'
|
||||
|
||||
denoise = getattr(skimage.restoration, f'denoise_{denoiser}')
|
||||
|
||||
@ -34,8 +36,28 @@ if requiresRaiseFiltering:
|
||||
def treatImage(imageFileName):
|
||||
global mean, numberOfImagesInMean
|
||||
imageFilePath = f'{imagesFolderPath}/{imageFileName}'
|
||||
imagePil = Image.open(imageFilePath)
|
||||
imageNpArray = img_as_float(np.array(imagePil))
|
||||
if imageFileName.endswith('.NEF'):
|
||||
imageFileName = 'r01b6aed6t.NEF'
|
||||
imageFilePath = f'{imagesFolderPath}/{imageFileName}'
|
||||
with rawpy.imread(imageFilePath) as raw:
|
||||
colorDesc = raw.color_desc.decode('ascii')
|
||||
assert colorDesc == 'RGBG'
|
||||
rawImageVisible = raw.raw_image_visible.copy()
|
||||
centerY = 628
|
||||
centerX = 3_014
|
||||
RANGE = 5
|
||||
rawImageVisible = rawImageVisible.astype(np.float64)
|
||||
rawImageVisibleShape = rawImageVisible.shape
|
||||
for y in range(0, rawImageVisibleShape[0], 2):
|
||||
for x in range(0, rawImageVisibleShape[1], 2):
|
||||
rawImageVisible[y, x] *= -1
|
||||
print(rawImageVisible[centerY - RANGE:centerY + RANGE, centerX - RANGE:centerX + RANGE])
|
||||
#greenRawImageVisible = raw.rawImageVisible
|
||||
# Pay attention to range of values expected by the denoiser.
|
||||
exit(1)
|
||||
else:
|
||||
imagePil = Image.open(imageFilePath)
|
||||
imageNpArray = img_as_float(np.array(imagePil))
|
||||
# As the arguments differ from a denoiser to the other should use a match instead.
|
||||
imageDenoisedNpArray = denoise(imageNpArray, channel_axis=-1, convert2ycbcr=True, rescale_sigma=True)
|
||||
imageNoiseNpArray = imageNpArray - imageDenoisedNpArray
|
||||
|
Loading…
Reference in New Issue
Block a user