From 3760164622a36f94a928fb54a5f047af08be597e Mon Sep 17 00:00:00 2001 From: Benjamin Loison <12752145+Benjamin-Loison@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:27:03 +0200 Subject: [PATCH] Add and use `colorRawImageVisible` --- datasets/raise/extract_noise.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/datasets/raise/extract_noise.py b/datasets/raise/extract_noise.py index 15d07aa..8e456b8 100755 --- a/datasets/raise/extract_noise.py +++ b/datasets/raise/extract_noise.py @@ -53,17 +53,27 @@ def treatImage(imageFileName, computeExtremes = False): 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: