Compare commits

..

2 Commits

Author SHA1 Message Date
Benjamin Loison
1a910d2e2c
Add a try with numpy.corrcoef 2024-05-13 12:39:59 +02:00
Benjamin Loison
6ed57bc477
Precise purpose of a part of code 2024-05-13 03:13:58 +02:00

View File

@ -96,8 +96,7 @@ returnSingleColorChannelImage = lambda singleColorChannelImage, _minColor, _maxC
# - the second one is about estimating better and better the PRNU of each camera, as consider more and more training images and measuring the resulting attribution of cameras
for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else []) + [False], 'Compute extremes'):
rescaleIfNeeded = returnSingleColorChannelImage if computeExtremes else rescaleRawImageForDenoiser
# As the second loop firstly compute noises of testing images.
# What about `MEAN` denoiser condition?
# As the second loop firstly if the denoiser is not `MEAN` or if `MEAN` predicts only on the whole training set, then compute noises of testing images.
if not computeExtremes:
print(f'{minColor=} {maxColor=}')
if DENOISER != Denoiser.MEAN or PREDICT_ONLY_ON_WHOLE_TRAINING_SET:
@ -139,7 +138,8 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
#plt.imsave(f'{escapeFilePath(actualCamera)}_{cameraTestingImageIndex}.png', cameraTestingImagesNoise[actualCamera][cameraTestingImageIndex])
# Loop over each camera to compute closeness between the considered testing image noise and the estimated PRNUs of the various cameras.
for camera in IMAGES_CAMERAS_FOLDER:
distance = rmsDiffNumpy(cameraTestingImagesNoise[actualCamera][cameraTestingImageIndex], camerasIterativeMean[camera].mean)
distance = abs(np.corrcoef(cameraTestingImagesNoise[actualCamera][cameraTestingImageIndex].flatten(), camerasIterativeMean[camera].mean.flatten()) - 1)
#distance = rmsDiffNumpy(cameraTestingImagesNoise[actualCamera][cameraTestingImageIndex], camerasIterativeMean[camera].mean)
print(f'{cameraTestingImageIndex=} {camera=} {actualCamera=} {distance=}')
if minimalDistance is None or distance < minimalDistance:
minimalDistance = distance