Add splitNxN compatible with 1 and 4

This commit is contained in:
Benjamin Loison 2024-03-29 12:44:42 +01:00
parent 60eceb575e
commit 4bf9ef8206
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

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