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: