Compare commits
4 Commits
a6ef3977dd
...
f4d8c028b2
Author | SHA1 | Date | |
---|---|---|---|
|
f4d8c028b2 | ||
|
3760164622 | ||
|
83a12f4e0a | ||
|
e080e841f5 |
@ -14,15 +14,16 @@ imagesFolderPathFileName = imagesFolderPath.replace('/', '_')
|
||||
denoiser = 'wavelet'
|
||||
npArrayFilePath = f'mean_{imagesFolderPathFileName}_{denoiser}.npy'
|
||||
|
||||
raiseNotFlatFields = False
|
||||
|
||||
denoise = getattr(skimage.restoration, f'denoise_{denoiser}')
|
||||
|
||||
mean = None
|
||||
numberOfImagesInMean = 0
|
||||
|
||||
imagesFileNames = os.listdir(imagesFolderPath + '/png')
|
||||
imagesFileNames = os.listdir(imagesFolderPath + ('/png' if raiseNotFlatFields else ''))
|
||||
|
||||
requiresRaiseFiltering = True
|
||||
if requiresRaiseFiltering:
|
||||
if raiseNotFlatFields:
|
||||
files = {}
|
||||
|
||||
with open('RAISE_all.csv') as csvfile:
|
||||
@ -32,31 +33,47 @@ if requiresRaiseFiltering:
|
||||
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 = [f'DSC0{imageIndex}.ARW' for imageIndex in range(2807, 2911)]
|
||||
|
||||
SKY = range(2_699, 2_807)
|
||||
WALL = range(2_807, 2_912)
|
||||
#imagesFileNames = [f'DSC0{imageIndex}.ARW' for imageIndex in SKY]
|
||||
|
||||
minColor = None
|
||||
maxColor = None
|
||||
|
||||
def treatImage(imageFileName, computeExtremes = False):
|
||||
global mean, numberOfImagesInMean, minColor, maxColor
|
||||
imageFileName = imageFileName.replace('.png', '.NEF')
|
||||
imageFilePath = f'{imagesFolderPath}/nef/{imageFileName}'
|
||||
if raiseNotFlatFields:
|
||||
imageFileName = imageFileName.replace('.png', '.NEF')
|
||||
imageFilePath = f'{imagesFolderPath}/nef/{imageFileName}'
|
||||
else:
|
||||
imageFilePath = f'{imagesFolderPath}/{imageFileName}'
|
||||
if imageFileName.endswith('.NEF') or imageFileName.endswith('.ARW'):
|
||||
with rawpy.imread(imageFilePath) as raw:
|
||||
colorDesc = raw.color_desc.decode('ascii')
|
||||
assert colorDesc == 'RGBG'
|
||||
assert np.array_equal(raw.raw_pattern, np.array([[0, 1], [3, 2]], dtype = np.uint8))
|
||||
# RG
|
||||
# GB
|
||||
rawImageVisible = raw.raw_image_visible.copy()
|
||||
greenRawImageVisible = rawImageVisible[1::2, ::2]
|
||||
|
||||
redRawImageVisible = rawImageVisible[::2, ::2]
|
||||
greenRightRawImageVisible = rawImageVisible[::2, 1::2]
|
||||
|
||||
greenBottomRawImageVisible = rawImageVisible[1::2, ::2]
|
||||
blueRawImageVisible = rawImageVisible[1::2, 1::2]
|
||||
|
||||
# Actual color to estimate the PRNU with.
|
||||
colorRawImageVisible = greenBottomRawImageVisible
|
||||
if computeExtremes:
|
||||
greenRawImageVisibleMin = greenRawImageVisible.min()
|
||||
greenRawImageVisibleMax = greenRawImageVisible.max()
|
||||
if minColor is None or greenRawImageVisibleMin < minColor:
|
||||
minColor = greenRawImageVisibleMin
|
||||
if maxColor is None or greenRawImageVisibleMax > maxColor:
|
||||
maxColor = greenRawImageVisibleMax
|
||||
colorRawImageVisibleMin = colorRawImageVisible.min()
|
||||
colorRawImageVisibleMax = colorRawImageVisible.max()
|
||||
if minColor is None or colorRawImageVisibleMin < minColor:
|
||||
minColor = colorRawImageVisibleMin
|
||||
if maxColor is None or colorRawImageVisibleMax > maxColor:
|
||||
maxColor = colorRawImageVisibleMax
|
||||
return
|
||||
imageNpArray = (greenRawImageVisible - minColor) / (maxColor - minColor)
|
||||
imageNpArray = (colorRawImageVisible - minColor) / (maxColor - minColor)
|
||||
# Pay attention to range of values expected by the denoiser.
|
||||
# Indeed if provide the thousands valued raw image, then the denoiser only returns values between 0 and 1 and making the difference between both look pointless.
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user