From 98426db9ddd68c06353f404e3384c39c8c382a9c Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 4 Jul 2024 04:11:12 +0200 Subject: [PATCH] Using matplotlib clipping --- 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 e3bb72e..888472e 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.1 +NOISE_FACTOR = 0.2 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): - imShow = axis.imshow(im) +def axisImShow(axis, im, vExtremes = [None, None]): + vMin, vMax = vExtremes + 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): @@ -77,13 +78,13 @@ for splitNXNIndex, splitNXN in enumerate(SPLIT_N_X_N_S): axis[1].set_title('First image Gaussian noise') axisImShow(axis[1], imageNoise) - axis[2].set_title('First image with Gaussian noise') + axis[2].set_title('First image with Gaussian noise\nClipped between 0 and 255') axisImShow(axis[2], np.clip(imageWithoutPrnuNpArray + imageNoise, 0, 255)) - axis[3].set_title('Actual Gaussian noised PRNU') - axisImShow(axis[3], prnuNpArray) + axis[3].set_title('Actual Gaussian noised PRNU\nClipped between -1 and 1') + axisImShow(axis[3], prnuNpArray, [-1, 1]) - axes[1][0].set_title('First image with Gaussian noise and PRNU') + axes[1][0].set_title('First image with Gaussian noise and PRNU\nClipped between 0 and 255') axisImShow(axes[1][0], np.clip(imageWithoutPrnuNpArray + prnuNpArray + imageNoise, 0, 255)) isFirstImage = False