Compare commits
3 Commits
6a9900df91
...
60a9dfe89c
Author | SHA1 | Date | |
---|---|---|---|
|
60a9dfe89c | ||
|
6e7e06b85c | ||
|
e3e3d44ca9 |
@ -111,6 +111,7 @@ 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'):
|
||||
@ -124,6 +125,7 @@ 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`
|
||||
@ -139,7 +141,8 @@ 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]#getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
|
||||
#singleColorChannelImages = singleColorChannelTestingImages[camera][cameraTestingImageIndex]
|
||||
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
|
||||
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
|
||||
|
||||
imagePrnuEstimateNpArray = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)
|
||||
@ -156,7 +159,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:
|
||||
if DENOISER == Denoiser.MEAN and not PREDICT_ONLY_ON_WHOLE_TRAINING_SET:
|
||||
for color in Color:
|
||||
cameraColorMeans[camera][color].add(singleColorChannelImages[color])
|
||||
imagePrnuEstimateNpArray = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)
|
||||
@ -182,7 +185,8 @@ 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]#getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
|
||||
#singleColorChannelImages = singleColorChannelTestingImages[camera][cameraTestingImageIndex]
|
||||
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
|
||||
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
|
||||
cameraTestingImageNoise = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)
|
||||
|
||||
|
@ -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 = getImageNpArray(imageFileName, False, color, Denoiser.MEAN)
|
||||
imageNpArray, minColor_, maxColor_ = getImageNpArray(imageFileName, False, color, Denoiser.MEAN, None, None)
|
||||
if singleColorChannelCropResolution is not None:
|
||||
imageNpArray = getImageCrop(imageNpArray, singleColorChannelCropResolution)
|
||||
imageNpArray = gaussian_filter(imageNpArray, sigma = 5)
|
||||
|
Loading…
Reference in New Issue
Block a user