60 lines
2.0 KiB
Python
Executable File
60 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from utils import Denoiser, Color, mergeSingleColorChannelImagesAccordingToBayerFilter
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
import os
|
|
|
|
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 = getCaseInsensitiveFilePath(PREFIX + f'{denoiser}_{color}.npy')
|
|
image = np.load(filePath)
|
|
return image
|
|
|
|
multipleColorsImageDenoisers = {}
|
|
|
|
DENOISERS = [
|
|
Denoiser.BILATERAL,
|
|
Denoiser.WAVELET,
|
|
Denoiser.MEAN,
|
|
]
|
|
|
|
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)
|
|
|
|
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):
|
|
vExtreme = extreme(list(multipleColorsImageDenoisers.values()))
|
|
return vExtreme
|
|
|
|
vMin, vMax = [getExtreme(extreme) for extreme in [np.min, np.max]]
|
|
|
|
for denoiser in DENOISERS:
|
|
multipleColorsImage = multipleColorsImageDenoisers[denoiser]
|
|
plt.imsave(PREFIX + f'{denoiser}_multiple_colors.png', multipleColorsImage)
|