Add gaussianNoise
to getPrnuShownAsSuch
but applies on the whole PRNU image
This commit is contained in:
parent
2d96bdc225
commit
ec7c5c6688
@ -16,13 +16,13 @@ def showImageWithMatplotlib(npArray, title = None, cmap = 'viridis'):
|
||||
def toPilImage(npArray):
|
||||
return Image.fromarray(npArray)
|
||||
|
||||
def getPrnuShownAsSuch(size):
|
||||
def getPrnuShownAsSuch(size, gaussianNoise = 0):
|
||||
# Supports `WIDTH` > `HEIGHT` and conversely.
|
||||
WIDTH, HEIGHT = size
|
||||
TEXT = 'PRNU'
|
||||
|
||||
image = Image.new('L', size)
|
||||
draw = ImageDraw.Draw(image)
|
||||
imagePil = Image.new('L', size)
|
||||
draw = ImageDraw.Draw(imagePil)
|
||||
fontPath = os.path.expanduser('~/.local/share/fonts/impact.ttf')
|
||||
for fontSize in range(1, HEIGHT + 1):
|
||||
font = ImageFont.truetype(fontPath, fontSize)
|
||||
@ -30,4 +30,5 @@ def getPrnuShownAsSuch(size):
|
||||
break
|
||||
# Center vertically, especially in the case `HEIGHT` > `WIDTH`.
|
||||
draw.text((0, HEIGHT // 2 - fontSize // 2), TEXT, 255, font = font)
|
||||
return np.array(image)
|
||||
imageNpArray = np.array(imagePil)
|
||||
return imageNpArray + randomGaussianImage(gaussianNoise, size[::-1])
|
@ -32,7 +32,10 @@ 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) * PRNU_FACTOR
|
||||
prnuNpArray = getPrnuShownAsSuch(IMAGE_SIZE_SHAPE, 100) * PRNU_FACTOR
|
||||
showImageWithMatplotlib(prnuNpArray)
|
||||
|
||||
##
|
||||
|
||||
def isIn256Range(x):
|
||||
return 0 <= x and x <= 255
|
||||
|
Loading…
x
Reference in New Issue
Block a user