Add and use colorRawImageVisible

This commit is contained in:
Benjamin Loison 2024-04-17 14:27:03 +02:00
parent 83a12f4e0a
commit 3760164622
No known key found for this signature in database

View File

@ -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: