Compare commits

...

5 Commits

Author SHA1 Message Date
Benjamin Loison
d8c7b8b0ef
Add and use getImagePrnuEstimatedNpArray 2024-05-03 02:03:59 +02:00
Benjamin Loison
878cff9aa2
Add and use getSingleColorChannelImages 2024-05-03 02:01:37 +02:00
Benjamin Loison
77b0b6dc6e
Make getMultipleColorsImage also return singleColorChannelImages 2024-05-03 01:59:39 +02:00
Benjamin Loison
591d7dc74a
Make getImageFilePath call implicit 2024-05-03 01:56:05 +02:00
Benjamin Loison
d696edeb3f
Add and use getMultipleColorsImage 2024-05-03 01:54:17 +02:00

View File

@ -58,6 +58,21 @@ def getImageFilePath(camera, cameraImageIndex):
imageFilePath = f'{IMAGES_CAMERAS_FOLDER[camera]}/{imageFileName}'
return imageFilePath
def getSingleColorChannelImages(camera, cameraImageIndex):
imageFilePath = getImageFilePath(camera, cameraImageIndex)
singleColorChannelImages = {color: rescaleIfNeeded(getColorChannel(imageFilePath, color)[:minimalColorChannelCameraResolution[0],:minimalColorChannelCameraResolution[1]], minColor, maxColor) for color in Color}
return singleColorChannelImages
def getMultipleColorsImage(singleColorChannelImages):
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
return multipleColorsImage
def getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage):
singleColorChannelDenoisedImages = {color: denoise(singleColorChannelImages[color], DENOISER) for color in Color}
multipleColorsDenoisedImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelDenoisedImages)
imagePrnuEstimateNpArray = multipleColorsImage - multipleColorsDenoisedImage
return imagePrnuEstimateNpArray
from utils import silentTqdm
#tqdm = silentTqdm
@ -70,31 +85,25 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
print('Extracting noise of testing images')
for camera in tqdm(IMAGES_CAMERAS_FOLDER, 'Camera'):
for cameraTestingImageIndex in tqdm(range(numberOfTestingImages), 'Camera testing image index'):
imageFilePath = getImageFilePath(camera, numberOfTrainingImages + cameraTestingImageIndex)
print(f'{imageFilePath=}')
print(f'{camera=} {numberOfTrainingImages + cameraTestingImageIndex=}')
# 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
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
imagePrnuEstimateNpArray = getImagePrnuEstimatedNpArray(singleColorChannelImages, multipleColorsImage)
cameraTestingImagesNoise[camera] = cameraTestingImagesNoise.get(camera, []) + [imagePrnuEstimateNpArray]
for cameraTrainingImageIndex in tqdm(range(minimumNumberOfImagesCameras if computeExtremes else numberOfTrainingImages), 'Camera training image index'):
for cameraIndex, camera in enumerate(tqdm(IMAGES_CAMERAS_FOLDER, 'Camera')):
imageFilePath = getImageFilePath(camera, cameraTrainingImageIndex)
singleColorChannelImages = {color: rescaleIfNeeded(getColorChannel(imageFilePath, color)[:minimalColorChannelCameraResolution[0],:minimalColorChannelCameraResolution[1]], minColor, maxColor) for color in Color}
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
singleColorChannelImages = getSingleColorChannelImages(camera, cameraTrainingImageIndex)
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
if computeExtremes:
minColor, maxColor = updateExtremes(multipleColorsImage, minColor, maxColor)
continue
singleColorChannelDenoisedImages = {color: denoise(singleColorChannelImages[color], DENOISER) for color in Color}
multipleColorsDenoisedImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelDenoisedImages)
imagePrnuEstimateNpArray = getImagePrnuEstimatedNpArray(singleColorChannelImages, multipleColorsImage)
imagePrnuEstimateNpArray = multipleColorsImage - multipleColorsDenoisedImage
cameraIterativeMean = camerasIterativeMean[camera]
cameraIterativeMean.add(imagePrnuEstimateNpArray)
if cameraIndex == numberOfCameras - 1: