Compare commits

..

No commits in common. "60a9dfe89ce6cbf403a3ff424d772f2e07f1cceb" and "6a9900df91e3bf3f5ade7b984c9fa0775fd21018" have entirely different histories.

2 changed files with 4 additions and 8 deletions

View File

@ -111,7 +111,6 @@ returnSingleColorChannelImage = lambda singleColorChannelImage, _minColor, _maxC
# Assume to have `{min,max}Color` hardcoded.
# Can just load to memory `getSingleColorChannelImages`, see [Robust_image_source_identification_on_modern_smartphones/issues/62#issuecomment-1861](https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/62#issuecomment-1861).
'''
rescaleIfNeeded = rescaleRawImageForDenoiser
cameraTrainingImages = {}
for cameraTrainingImageIndex in tqdm(range(numberOfTrainingImages), 'Load to memory camera training image'):
@ -125,7 +124,6 @@ for camera in IMAGES_CAMERAS_FOLDER:
for cameraTestingImageIndex in tqdm(range(numberOfTestingImages), 'Load to memory camera testing image'):
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
singleColorChannelTestingImages[camera] += [singleColorChannelImages]
'''
# 2 loops:
# - the first one is about computing `{min,max}Color`
@ -141,8 +139,7 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
for cameraTestingImageIndex in tqdm(range(numberOfTestingImages), 'Camera testing image index'):
print(f'{camera=} {numberOfTrainingImages + cameraTestingImageIndex=}')
#singleColorChannelImages = singleColorChannelTestingImages[camera][cameraTestingImageIndex]
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
singleColorChannelImages = singleColorChannelTestingImages[camera][cameraTestingImageIndex]#getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
imagePrnuEstimateNpArray = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)
@ -159,7 +156,7 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
minColor, maxColor = updateExtremes(multipleColorsImage, minColor, maxColor)
continue
if DENOISER == Denoiser.MEAN and not PREDICT_ONLY_ON_WHOLE_TRAINING_SET:
if DENOISER == Denoiser.MEAN:
for color in Color:
cameraColorMeans[camera][color].add(singleColorChannelImages[color])
imagePrnuEstimateNpArray = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)
@ -185,8 +182,7 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
if DENOISER != Denoiser.MEAN:
cameraTestingImageNoise = cameraTestingImagesNoise[actualCamera][cameraTestingImageIndex]
else:
#singleColorChannelImages = singleColorChannelTestingImages[camera][cameraTestingImageIndex]
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
singleColorChannelImages = singleColorChannelTestingImages[camera][cameraTestingImageIndex]#getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
cameraTestingImageNoise = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)

View File

@ -205,7 +205,7 @@ def getColorMeans(imagesFileNames, colors, singleColorChannelCropResolution = No
for color in colors:
colorIterativeMean = iterativeMean()
for imageFileName in tqdm(imagesFileNames, f'Computing mean of {str(color).replace("_", " ")} colored images'):
imageNpArray, minColor_, maxColor_ = getImageNpArray(imageFileName, False, color, Denoiser.MEAN, None, None)
imageNpArray = getImageNpArray(imageFileName, False, color, Denoiser.MEAN)
if singleColorChannelCropResolution is not None:
imageNpArray = getImageCrop(imageNpArray, singleColorChannelCropResolution)
imageNpArray = gaussian_filter(imageNpArray, sigma = 5)