Compare commits

...

2 Commits

View File

@ -5,6 +5,8 @@ from tqdm import tqdm
from utils import denoise
from skimage import img_as_float
import sys
import os
from random import shuffle
sys.path.insert(0, '../../algorithms/distance/')
@ -12,19 +14,19 @@ from rms_diff import rmsDiffNumpy
NUMBER_OF_SUBGROUPS = 1
DENOISER = 'wavelet'
IMAGES_FOLDER = 'flat-field/TIF'
imagesFileNames = os.listdir(IMAGES_FOLDER)
numberOfImagesPerSubgroup = len(imagesFileNames) // NUMBER_OF_SUBGROUPS
# 1
imagesFileNames = os.listdir(IMAGES_FOLDER)
# To not have a bias (chronological for instance) when split to make subgroups.
shuffle(imagesFileNames)
numberOfImagesPerSubgroup = len(imagesFileNames) // NUMBER_OF_SUBGROUPS
numberOfImagesThresholds = range(numberOfImagesPerSubgroup, numberOfImagesPerSubgroup + 1)
# Assume random image order to not introduce a bias.
subgroupsPrnuEstimatesNpArray = []
for subgroupIndex in range(NUMBER_OF_SUBGROUPS):
for subgroupIndex in tqdm(range(NUMBER_OF_SUBGROUPS), 'Subgroup'):
imagesPrnuEstimateNpArray = []
for imageFileName in tqdm(imagesFileNames[numberOfImagesPerSubgroup * subgroupIndex : numberOfImagesPerSubgroup * (subgroupIndex + 1)]):
subgroupImagesFileNames = imagesFileNames[numberOfImagesPerSubgroup * subgroupIndex : numberOfImagesPerSubgroup * (subgroupIndex + 1)]
for imageFileName in tqdm(subgroupImagesFileNames, f'Image of subgroup {subgroupIndex}'):
imagePath = f'{IMAGES_FOLDER}/{imageFileName}'
imagePil = Image.open(imagePath)
imageNpArray = img_as_float(np.array(imagePil))
@ -39,7 +41,7 @@ for subgroupIndex in range(NUMBER_OF_SUBGROUPS):
subgroupsPrnuEstimatesNpArray += [subgroupPrnuEstimateNpArray]
rmss = []
for numberOfImagesIndex, numberOfImages in enumerate(numberOfImagesThresholds):
for numberOfImagesIndex in range(len(numberOfImagesThresholds)):
rms = rmsDiffNumpy(subgroupsPrnuEstimatesNpArray[0][numberOfImagesIndex], subgroupsPrnuEstimatesNpArray[1][numberOfImagesIndex])
rmss += [rms]