Update old merge_with_same_color_scale_single_color_channel_images_according_to_bayer_filter.py

This commit is contained in:
Benjamin Loison 2024-05-15 15:43:16 +02:00
parent 8ec292ba11
commit f7c08849dc
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -3,11 +3,19 @@
from utils import Denoiser, Color, mergeSingleColorChannelImagesAccordingToBayerFilter
import matplotlib.pyplot as plt
import numpy as np
import os
PREFIX = 'means/mean_rafael_230424_'
PREFIX = 'means/mean_flat-field_nef_'
fileNames = os.listdir(os.path.dirname(PREFIX))
fileNamesLowercase = list(map(str.lower, fileNames))
# Assume that there are no 2 file names just differing by case.
def getCaseInsensitiveFilePath(filePath):
return os.path.dirname(filePath) + '/' + fileNames[fileNamesLowercase.index(os.path.basename(filePath).lower())]
def getImageByColor(color, denoiser):
filePath = PREFIX + f'{denoiser}_{color}.npy'
filePath = getCaseInsensitiveFilePath(PREFIX + f'{denoiser}_{color}.npy')
image = np.load(filePath)
return image
@ -19,13 +27,25 @@ DENOISERS = [
Denoiser.MEAN,
]
for denoiser in DENOISERS:
figure, axes = plt.subplots(nrows = len(DENOISERS) + 1)
plt.suptitle('PRNU estimate distribution of values for RAISE flat-field images')
for denoiserIndex, denoiser in enumerate(DENOISERS):
singleColorChannelImages = {color: getImageByColor(color, denoiser) for color in Color}
multipleColorsImage = mergeSingleColorChannelImagesAccordingToBayerFilter(singleColorChannelImages)
multipleColorsImageDenoisers[denoiser] = multipleColorsImage
axis = axes[denoiserIndex]
labels = [str(color).replace('_', ' ') for color in Color]
axis.boxplot(list(map(np.ravel, singleColorChannelImages.values())), labels = labels)
axis.grid(True)
axis.set_title(denoiser)
plt.boxplot(list(map(np.ravel, multipleColorsImageDenoisers.values())), labels = DENOISERS)
plt.grid(True)
axis = axes[-1]
axis.boxplot(list(map(np.ravel, multipleColorsImageDenoisers.values())), labels = DENOISERS)
axis.grid(True)
axis.set_title('Merged single color channels')
plt.tight_layout()
plt.show()
def getExtreme(extreme):