Make Gaussian noise in getPrnuShownAsSuch only on text

This commit is contained in:
Benjamin Loison 2024-03-29 13:22:36 +01:00
parent ec7c5c6688
commit 81852d5dc6
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8
2 changed files with 10 additions and 6 deletions

View File

@ -31,4 +31,11 @@ def getPrnuShownAsSuch(size, gaussianNoise = 0):
# Center vertically, especially in the case `HEIGHT` > `WIDTH`.
draw.text((0, HEIGHT // 2 - fontSize // 2), TEXT, 255, font = font)
imageNpArray = np.array(imagePil)
return imageNpArray + randomGaussianImage(gaussianNoise, size[::-1])
gaussianNoiseNpArray = randomGaussianImage(gaussianNoise, size[::-1])
#prnuShownAsSuch = imageNpArray + gaussianNoiseNpArray
prnuShownAsSuch = imageNpArray
for y in range(HEIGHT):
for x in range(WIDTH):
if prnuShownAsSuch[y, x] != 0:
prnuShownAsSuch[y, x] += gaussianNoiseNpArray[y, x]
return prnuShownAsSuch

View File

@ -25,17 +25,14 @@ datasetPath = 'no_noise_images'
# In addition to the range difference, note that the distribution in the first set of images was a Gaussian and here is very different and specific.
PRNU_FACTOR = 0.01
NOISE_FACTOR = 0.1
SPLIT_N_X_N = 4
SPLIT_N_X_N = 1
IMAGE_SIZE_SHAPE = [dimension // SPLIT_N_X_N for dimension in (704, 469)]
np.random.seed(0)
#prnuNpArray = 255 * randomGaussianImage(scale = PRNU_FACTOR, size = IMAGE_SIZE_SHAPE)
prnuNpArray = getPrnuShownAsSuch(IMAGE_SIZE_SHAPE, 100) * PRNU_FACTOR
showImageWithMatplotlib(prnuNpArray)
##
prnuNpArray = getPrnuShownAsSuch(IMAGE_SIZE_SHAPE, 255) * PRNU_FACTOR
def isIn256Range(x):
return 0 <= x and x <= 255