Leverage utils.py denoise in split_and_compare_prnus_of_subgroups.py

This commit is contained in:
Benjamin Loison 2024-04-26 13:58:00 +02:00
parent 9d2903af60
commit 9c469cf67a
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

View File

@ -2,7 +2,7 @@ from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
from skimage.restoration import denoise_tv_chambolle
from utils import denoise
from skimage import img_as_float
import sys
@ -15,6 +15,7 @@ sys.path.insert(0, '../../algorithms/distance/')
from rms_diff import rmsDiffNumpy
NUMBER_OF_SUBGROUPS = 1
DENOISER = 'wavelet'
IMAGES_FOLDER = 'flat-field/TIF'
imagesFileNames = os.listdir(IMAGES_FOLDER)
@ -31,7 +32,7 @@ for subgroupIndex in range(NUMBER_OF_SUBGROUPS):
imagePath = f'{IMAGES_FOLDER}/{imageFileName}'
imagePil = Image.open(imagePath)
imageNpArray = img_as_float(np.array(imagePil))
imagePrnuEstimateNpArray = imageNpArray - denoise_tv_chambolle(imageNpArray, weight=0.2, channel_axis=-1)
imagePrnuEstimateNpArray = imageNpArray - denoise(imageNpArray, DENOISER)
imagesPrnuEstimateNpArray += [imagePrnuEstimateNpArray]
subgroupPrnuEstimateNpArray = []
@ -46,7 +47,7 @@ for numberOfImagesIndex, numberOfImages in enumerate(numberOfImagesThresholds):
rms = rmsDiffNumpy(subgroupsPrnuEstimatesNpArray[0][numberOfImagesIndex], subgroupsPrnuEstimatesNpArray[1][numberOfImagesIndex])
rmss += [rms]
plt.title('RMS between both subgroups estimated PRNUs for a given number of images among them')
plt.title(f'RMS between both subgroups estimated PRNUs with {DENOISER} denoiser for a given number of images among them')
plt.xlabel('Number of images of each subgroup')
plt.ylabel('RMS between both subgroups estimated PRNUs')
plt.plot(rmss)