Add and use getSingleColorChannelImages

This commit is contained in:
Benjamin Loison 2024-05-03 02:01:37 +02:00
parent 77b0b6dc6e
commit 878cff9aa2
No known key found for this signature in database

View File

@ -58,11 +58,14 @@ def getImageFilePath(camera, cameraImageIndex):
imageFilePath = f'{IMAGES_CAMERAS_FOLDER[camera]}/{imageFileName}'
return imageFilePath
def getSingleColorChannelAndMultipleColorsImage(camera, cameraImageIndex):
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 singleColorChannelImages, multipleColorsImage
return multipleColorsImage
from utils import silentTqdm
#tqdm = silentTqdm
@ -78,7 +81,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, multipleColorsImage = getSingleColorChannelAndMultipleColorsImage(camera, numberOfTrainingImages + cameraTestingImageIndex)
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
# Should make a function
singleColorChannelDenoisedImages = {color: denoise(singleColorChannelImages[color], DENOISER) for color in Color}
@ -88,7 +92,8 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
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')):
singleColorChannelImages, multipleColorsImage = getSingleColorChannelAndMultipleColorsImage(camera, cameraTrainingImageIndex)
singleColorChannelImages = getSingleColorChannelImages(camera, cameraTrainingImageIndex)
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
if computeExtremes:
minColor, maxColor = updateExtremes(multipleColorsImage, minColor, maxColor)