This commit is contained in:
2024-07-04 04:03:54 +02:00
parent 6f961a46cf
commit 9d20940cb1

View File

@@ -24,7 +24,7 @@ datasetPath = 'no_noise_images'
# Note that contrarily to `datasets/fake/`, here we do not have images being Gaussian with `scale` `1` but actual images with pixel values between 0 and 255. # Note that contrarily to `datasets/fake/`, here we do not have images being Gaussian with `scale` `1` but actual images with pixel values between 0 and 255.
# 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. # 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 PRNU_FACTOR = 0.01
NOISE_FACTOR = 0.1 NOISE_FACTOR = 0.2
np.random.seed(0) np.random.seed(0)
@@ -34,8 +34,8 @@ SPLIT_N_X_N_S = [1, 2, 4]
fig, axes = plt.subplots(2, 4) fig, axes = plt.subplots(2, 4)
fig.suptitle('PRNU estimation with different number of images having Gaussian noise and Gaussian noised PRNU') fig.suptitle('PRNU estimation with different number of images having Gaussian noise and Gaussian noised PRNU')
def axisImShow(axis, im): def axisImShow(axis, im, cmap = None):
imShow = axis.imshow(im) imShow = axis.imshow(im, cmap = cmap)
plt.colorbar(imShow, label = 'Intensity', ax = axis, orientation = 'horizontal') plt.colorbar(imShow, label = 'Intensity', ax = axis, orientation = 'horizontal')
for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S): for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S):
@@ -71,20 +71,26 @@ for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S):
if splitNXNIndex == 0 and isFirstImage: if splitNXNIndex == 0 and isFirstImage:
axis = axes[0] axis = axes[0]
images = [imageWithoutPrnuNpArrayTile, imageWithoutPrnuNpArray + imageNoise, imageWithoutPrnuNpArray + prnuNpArray + imageNoise]
vMin = np.min(images)#min([np.min(image) for image in [imageWithoutPrnuNpArrayTile, imageWithoutPrnuNpArray + imageNoise, imageWithoutPrnuNpArray + prnuNpArray + imageNoise]])
vMax = np.max(images)
cmap = (vMin, vMax)
#print(f'{vMin=}')
axis[0].set_title('First image without noise') axis[0].set_title('First image without noise')
axisImShow(axis[0], imageWithoutPrnuNpArrayTile) axisImShow(axis[0], imageWithoutPrnuNpArrayTile, cmap = cmap)
axis[1].set_title('First image Gaussian noise') axis[1].set_title('First image Gaussian noise')
axisImShow(axis[1], imageNoise) axisImShow(axis[1], imageNoise)
axis[2].set_title('First image with Gaussian noise') axis[2].set_title('First image with Gaussian noise')
axisImShow(axis[2], np.clip(imageWithoutPrnuNpArray + imageNoise, 0, 255)) axisImShow(axis[2], imageWithoutPrnuNpArray + imageNoise, cmap = cmap)
axis[3].set_title('Actual Gaussian noised PRNU') axis[3].set_title('Actual Gaussian noised PRNU')
axisImShow(axis[3], prnuNpArray) axisImShow(axis[3], prnuNpArray)
axes[1][0].set_title('First image with Gaussian noise and PRNU') axes[1][0].set_title('First image with Gaussian noise and PRNU')
axisImShow(axes[1][0], np.clip(imageWithoutPrnuNpArray + prnuNpArray + imageNoise, 0, 255)) axisImShow(axes[1][0], imageWithoutPrnuNpArray + prnuNpArray + imageNoise, cmap = cmap)
isFirstImage = False isFirstImage = False
#assert all([isIn256Range(extreme) for extreme in [imageWithPrnuNpArray.max(), imageWithPrnuNpArray.min()]]), 'Adding the PRNU resulted in out of 256 bounds image' #assert all([isIn256Range(extreme) for extreme in [imageWithPrnuNpArray.max(), imageWithPrnuNpArray.min()]]), 'Adding the PRNU resulted in out of 256 bounds image'