From 5bc0337dc8871f5b003dc4e8f795a4b28a6d5b8b Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 4 Jul 2024 04:08:10 +0200 Subject: [PATCH] Forcing color map --- datasets/noise_free_test_images/estimate_prnu.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/datasets/noise_free_test_images/estimate_prnu.py b/datasets/noise_free_test_images/estimate_prnu.py index 9b6b694..820e44e 100644 --- a/datasets/noise_free_test_images/estimate_prnu.py +++ b/datasets/noise_free_test_images/estimate_prnu.py @@ -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. # 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.2 +NOISE_FACTOR = 0.1 np.random.seed(0) @@ -34,8 +34,9 @@ SPLIT_N_X_N_S = [1, 2, 4] fig, axes = plt.subplots(2, 4) fig.suptitle('PRNU estimation with different number of images having Gaussian noise and Gaussian noised PRNU') -def axisImShow(axis, im, cmap = None): - imShow = axis.imshow(im, cmap = cmap) +def axisImShow(axis, im, cMap = (None, None)): + vMin, vMax = cMap + imShow = axis.imshow(im, vmin = vMin, vmax = vMax) plt.colorbar(imShow, label = 'Intensity', ax = axis, orientation = 'horizontal') for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S): @@ -74,23 +75,23 @@ for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S): 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) + cMap = (vMin, vMax) #print(f'{vMin=}') axis[0].set_title('First image without noise') - axisImShow(axis[0], imageWithoutPrnuNpArrayTile, cmap = cmap) + axisImShow(axis[0], imageWithoutPrnuNpArrayTile, cMap = cMap) axis[1].set_title('First image Gaussian noise') axisImShow(axis[1], imageNoise) axis[2].set_title('First image with Gaussian noise') - axisImShow(axis[2], imageWithoutPrnuNpArray + imageNoise, cmap = cmap) + axisImShow(axis[2], imageWithoutPrnuNpArray + imageNoise, cMap = cMap) axis[3].set_title('Actual Gaussian noised PRNU') axisImShow(axis[3], prnuNpArray) axes[1][0].set_title('First image with Gaussian noise and PRNU') - axisImShow(axes[1][0], imageWithoutPrnuNpArray + prnuNpArray + imageNoise, cmap = cmap) + axisImShow(axes[1][0], imageWithoutPrnuNpArray + prnuNpArray + imageNoise, cMap = cMap) isFirstImage = False #assert all([isIn256Range(extreme) for extreme in [imageWithPrnuNpArray.max(), imageWithPrnuNpArray.min()]]), 'Adding the PRNU resulted in out of 256 bounds image'