Compare commits

..

2 Commits

Author SHA1 Message Date
115bab4b4c
Add and use getEstimatedPrnu 2024-06-05 16:47:24 +02:00
31da324702
Compute mean PRNU estimate from scratch 2024-06-05 16:41:44 +02:00

View File

@ -8,23 +8,33 @@ sys.path.insert(0, '../')
from utils import isARawImage, Color, getColorChannel, mergeSingleColorChannelImagesAccordingToBayerFilter, iterativeMean
folder = '../rafael/230424'
meanImages = iterativeMean()
filePaths = [f'{folder}/{file}' for file in os.listdir(folder) if isARawImage(file)]
FOLDERS = {
'Rafael 23/04/24': '../rafael/230424',
'RAISE flat-field': '../flat-field/nef',
'RAISE not flat-field': '../not_flat-field/nef',
}
for filePath in tqdm(filePaths):
def getImageMergedColorChannels(filePath):
imageColorChannels = {color: getColorChannel(filePath, color) for color in Color}
imageMergedColorChannels = mergeSingleColorChannelImagesAccordingToBayerFilter(imageColorChannels)
meanImages.add(imageMergedColorChannels)
return imageMergedColorChannels
#print(meanImages.mean.shape)
def getEstimatedPrnu(folder):
meanImages = iterativeMean()
filePaths = [f'{folder}/{file}' for file in os.listdir(folder) if isARawImage(file)]
# Is not there anything clever than this to do? See [Robust_image_source_identification_on_modern_smartphones/issues/72](https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/72).
estimatedPrnu = iterativeMean()
for filePath in tqdm(filePaths):
imageColorChannels = {color: getColorChannel(filePath, color) for color in Color}
imageMergedColorChannels = mergeSingleColorChannelImagesAccordingToBayerFilter(imageColorChannels)
estimatedPrnu.add(imageMergedColorChannels - meanImages.mean)
for filePath in tqdm(filePaths, 'Compute mean image'):
imageMergedColorChannels = getImageMergedColorChannels(filePath)
meanImages.add(imageMergedColorChannels)
plt.imshow(estimatedPrnu.mean)
# Is not there anything clever than this to do? See [Robust_image_source_identification_on_modern_smartphones/issues/72](https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/72).
estimatedPrnu = iterativeMean()
for filePath in tqdm(filePaths, 'Compute estimated PRNU'):
imageMergedColorChannels = getImageMergedColorChannels(filePath)
estimatedPrnu.add(imageMergedColorChannels - meanImages.mean)
return estimatedPrnu.mean
estimatedPrnu = getEstimatedPrnu(FOLDERS['Rafael 23/04/24'])
plt.imshow(estimatedPrnu)
plt.show()