Add mean
DENOISER
support
This commit is contained in:
parent
9d33abcea3
commit
fd6a9868fe
@ -3,7 +3,7 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from tqdm import tqdm
|
||||
from utils import denoise, iterativeMean, getColorChannel, escapeFilePath, Color, mergeSingleColorChannelImagesAccordingToBayerFilter, rescaleRawImageForDenoiser, updateExtremes, saveNpArray
|
||||
from utils import denoise, iterativeMean, getColorChannel, escapeFilePath, Color, mergeSingleColorChannelImagesAccordingToBayerFilter, rescaleRawImageForDenoiser, updateExtremes, saveNpArray, getColorMeans
|
||||
import sys
|
||||
import os
|
||||
import random
|
||||
@ -12,7 +12,7 @@ sys.path.insert(0, '../../algorithms/distance/')
|
||||
|
||||
from rms_diff import rmsDiffNumpy
|
||||
|
||||
DENOISER = 'wavelet'
|
||||
DENOISER = 'mean'
|
||||
IMAGES_CAMERAS_FOLDER = {
|
||||
'RAISE': 'flat-field/nef',
|
||||
'Rafael 23/04/24': 'rafael/230424',
|
||||
@ -27,7 +27,7 @@ random.seed(0)
|
||||
for camera in IMAGES_CAMERAS_FOLDER:
|
||||
random.shuffle(imagesCamerasFileNames[camera])
|
||||
|
||||
minimumNumberOfImagesCameras = 16#min([len(imagesCamerasFileNames[camera]) for camera in IMAGES_CAMERAS_FOLDER])
|
||||
minimumNumberOfImagesCameras = min([len(imagesCamerasFileNames[camera]) for camera in IMAGES_CAMERAS_FOLDER])
|
||||
for camera in IMAGES_CAMERAS_FOLDER:
|
||||
imagesCamerasFileNames[camera] = imagesCamerasFileNames[camera][:minimumNumberOfImagesCameras]
|
||||
print(camera, imagesCamerasFileNames[camera])
|
||||
@ -67,12 +67,16 @@ def getMultipleColorsImage(singleColorChannelImages):
|
||||
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
|
||||
return multipleColorsImage
|
||||
|
||||
def getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage):
|
||||
singleColorChannelDenoisedImages = {color: denoise(singleColorChannelImages[color], DENOISER) for color in Color}
|
||||
def getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera):
|
||||
singleColorChannelDenoisedImages = {color: denoise(singleColorChannelImages[color], DENOISER) if DENOISER != 'mean' else cameraColorMeans[camera][color] for color in Color}
|
||||
multipleColorsDenoisedImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelDenoisedImages)
|
||||
imagePrnuEstimateNpArray = multipleColorsImage - multipleColorsDenoisedImage
|
||||
return imagePrnuEstimateNpArray
|
||||
|
||||
imagesCamerasFilePaths = {camera: [f'{IMAGES_CAMERAS_FOLDER[camera]}/{imagesCamerasFileName}' for imagesCamerasFileName in imagesCamerasFileNames[camera]] for camera in imagesCamerasFileNames}
|
||||
#print(imagesCamerasFilePaths)
|
||||
cameraColorMeans = {camera: getColorMeans(imagesCamerasFilePaths[camera], Color, DENOISER) for camera in imagesCamerasFilePaths}
|
||||
|
||||
from utils import silentTqdm
|
||||
#tqdm = silentTqdm
|
||||
|
||||
@ -90,7 +94,7 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
|
||||
singleColorChannelImages = getSingleColorChannelImages(camera, numberOfTrainingImages + cameraTestingImageIndex)
|
||||
multipleColorsImage = getMultipleColorsImage(singleColorChannelImages)
|
||||
|
||||
imagePrnuEstimateNpArray = getImagePrnuEstimatedNpArray(singleColorChannelImages, multipleColorsImage)
|
||||
imagePrnuEstimateNpArray = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)
|
||||
|
||||
cameraTestingImagesNoise[camera] = cameraTestingImagesNoise.get(camera, []) + [imagePrnuEstimateNpArray]
|
||||
for cameraTrainingImageIndex in tqdm(range(minimumNumberOfImagesCameras if computeExtremes else numberOfTrainingImages), 'Camera training image index'):
|
||||
@ -102,7 +106,7 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
|
||||
minColor, maxColor = updateExtremes(multipleColorsImage, minColor, maxColor)
|
||||
continue
|
||||
|
||||
imagePrnuEstimateNpArray = getImagePrnuEstimatedNpArray(singleColorChannelImages, multipleColorsImage)
|
||||
imagePrnuEstimateNpArray = getImagePrnuEstimateNpArray(singleColorChannelImages, multipleColorsImage, camera)
|
||||
|
||||
cameraIterativeMean = camerasIterativeMean[camera]
|
||||
cameraIterativeMean.add(imagePrnuEstimateNpArray)
|
||||
|
Loading…
x
Reference in New Issue
Block a user