From 4bf9ef82066ee0d8a5a0015364ea4e1671e72afc Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Fri, 29 Mar 2024 12:44:42 +0100 Subject: [PATCH] Add `splitNxN` compatible with `1` and `4` --- datasets/noise_free_test_images/estimate_prnu.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datasets/noise_free_test_images/estimate_prnu.py b/datasets/noise_free_test_images/estimate_prnu.py index 91f79b5..6b13fab 100644 --- a/datasets/noise_free_test_images/estimate_prnu.py +++ b/datasets/noise_free_test_images/estimate_prnu.py @@ -30,8 +30,9 @@ IMAGE_SIZE_SHAPE_4x4 = [size // 4 for size in IMAGE_SIZE_SHAPE] np.random.seed(0) +splitNxN = 4 #prnuNpArray = 255 * randomGaussianImage(scale = PRNU_FACTOR, size = IMAGE_SIZE_SHAPE) -prnuPil = Image.open('prnu_4x4_noise.png').convert('F') +prnuPil = Image.open(f'prnu_{"4x4_" if splitNxN == 4 else ""}noise.png').convert('F') prnuNpArray = np.array(prnuPil) * PRNU_FACTOR def isIn256Range(x): @@ -45,8 +46,8 @@ for imageName in os.listdir(datasetPath): imageWithoutPrnuPil = Image.open(imagePath).convert('F') imageWithoutPrnuNpArray = np.array(imageWithoutPrnuPil) - m = imageWithoutPrnuNpArray.shape[0] // 4 - n = imageWithoutPrnuNpArray.shape[1] // 4 + m = imageWithoutPrnuNpArray.shape[0] // splitNxN + n = imageWithoutPrnuNpArray.shape[1] // splitNxN imageWithoutPrnuNpArrayTiles = [imageWithoutPrnuNpArray[x : x + m, y : y + n] for x in range(0, imageWithoutPrnuNpArray.shape[0], m) for y in range(0, imageWithoutPrnuNpArray.shape[1], n)] for imageWithoutPrnuNpArrayTile in imageWithoutPrnuNpArrayTiles: