Move denoising testing images to work even if provide minColor
and maxColor
(#63)
This commit is contained in:
parent
3c403dbed3
commit
a8725e5e88
@ -43,11 +43,11 @@ for camera in IMAGES_CAMERAS_FOLDER:
|
||||
imageFileName = imagesCamerasFileNames[camera][0]
|
||||
imageFilePath = f'{IMAGES_CAMERAS_FOLDER[camera]}/{imageFileName}'
|
||||
singleColorChannelImagesShape = getColorChannel(imageFilePath, Color.RED).shape
|
||||
#print(singleColorChannelImagesShape)
|
||||
if minimalColorChannelCameraResolution is None or singleColorChannelImagesShape < minimalColorChannelCameraResolution:
|
||||
minimalColorChannelCameraResolution = singleColorChannelImagesShape
|
||||
#print(minimalColorChannelCameraResolution)
|
||||
#exit(1)
|
||||
|
||||
minColor = 13#None
|
||||
maxColor = 7497#None
|
||||
|
||||
accuracy = []
|
||||
numberOfTrainingImages = int(minimumNumberOfImagesCameras * TRAINING_PORTION)
|
||||
@ -58,6 +58,23 @@ returnSingleColorChannelImage = lambda singleColorChannelImage, _minColor, _maxC
|
||||
|
||||
for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else []) + [False], 'Compute extremes'):
|
||||
rescaleIfNeeded = returnSingleColorChannelImage if computeExtremes else rescaleRawImageForDenoiser
|
||||
if not computeExtremes:
|
||||
print(f'{minColor=} {maxColor=}')
|
||||
print('Extracting noise of testing images')
|
||||
for camera in tqdm(IMAGES_CAMERAS_FOLDER, 'Camera'):
|
||||
for cameraTestingImageIndex in tqdm(range(numberOfTestingImages), 'Camera testing image index'):
|
||||
# Should make a function
|
||||
imageFileName = imagesCamerasFileNames[camera][numberOfTrainingImages + cameraTestingImageIndex]
|
||||
imageFilePath = f'{IMAGES_CAMERAS_FOLDER[camera]}/{imageFileName}'
|
||||
|
||||
# Should make a function
|
||||
singleColorChannelImages = {color: rescaleIfNeeded(getColorChannel(imageFilePath, color)[:minimalColorChannelCameraResolution[0],:minimalColorChannelCameraResolution[1]], minColor, maxColor) for color in Color}
|
||||
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
|
||||
singleColorChannelDenoisedImages = {color: denoise(singleColorChannelImages[color], DENOISER) for color in Color}
|
||||
multipleColorsDenoisedImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelDenoisedImages)
|
||||
imagePrnuEstimateNpArray = multipleColorsImage - multipleColorsDenoisedImage
|
||||
|
||||
cameraTestingImagesNoise[camera] = cameraTestingImagesNoise.get(camera, []) + [multipleColorsDenoisedImage]
|
||||
for cameraTrainingImageIndex in tqdm(range(minimumNumberOfImagesCameras if computeExtremes else numberOfTrainingImages), 'Camera training image index'):
|
||||
for cameraIndex, camera in enumerate(tqdm(IMAGES_CAMERAS_FOLDER, 'Camera')):
|
||||
imageFileName = imagesCamerasFileNames[camera][cameraTrainingImageIndex]
|
||||
@ -92,23 +109,6 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
|
||||
if cameraPredicted == actualCamera:
|
||||
numberOfTrainingImagesAccuracy += 1
|
||||
accuracy += [numberOfTrainingImagesAccuracy / (numberOfTestingImages * numberOfCameras)]
|
||||
if computeExtremes:
|
||||
print(f'{minColor=} {maxColor=}')
|
||||
print('Extracting noise of testing images')
|
||||
for camera in tqdm(IMAGES_CAMERAS_FOLDER, 'Camera'):
|
||||
for cameraTestingImageIndex in tqdm(range(numberOfTestingImages), 'Camera testing image index'):
|
||||
# Should make a function
|
||||
imageFileName = imagesCamerasFileNames[camera][numberOfTrainingImages + cameraTestingImageIndex]
|
||||
imageFilePath = f'{IMAGES_CAMERAS_FOLDER[camera]}/{imageFileName}'
|
||||
|
||||
# Should make a function
|
||||
singleColorChannelImages = {color: rescaleIfNeeded(getColorChannel(imageFilePath, color)[:minimalColorChannelCameraResolution[0],:minimalColorChannelCameraResolution[1]], minColor, maxColor) for color in Color}
|
||||
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
|
||||
singleColorChannelDenoisedImages = {color: denoise(singleColorChannelImages[color], DENOISER) for color in Color}
|
||||
multipleColorsDenoisedImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelDenoisedImages)
|
||||
imagePrnuEstimateNpArray = multipleColorsImage - multipleColorsDenoisedImage
|
||||
|
||||
cameraTestingImagesNoise[camera] = cameraTestingImagesNoise.get(camera, []) + [multipleColorsDenoisedImage]
|
||||
|
||||
for camera in IMAGES_CAMERAS_FOLDER:
|
||||
plt.imsave(f'{setting}_estimated_prnu_subgroup_{escapeFilePath(camera)}.png', (camerasIterativeMean[camera].mean))
|
||||
|
Loading…
x
Reference in New Issue
Block a user