Support lowest correlation in find_consecutive_most_similar_images.py

This commit is contained in:
Benjamin Loison 2024-05-31 16:05:36 +02:00
parent 7f7e78cafb
commit fbd7cb01e1
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8

15
datasets/raise/find_consecutive_most_similar_images.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/python3
import os
from utils import getColorChannel, Color, mergeSingleColorChannelImagesAccordingToBayerFilter, isARawImage
from tqdm import tqdm
@ -22,8 +24,9 @@ def crop(image, yRange, xRange):
lastMergedSingleColorChannelImage = None
lastCorrelation = None
highestCorrelation = None
highestCorrelationFile = None
# Supports both highest and lowest.
extremeCorrelation = None
extremeCorrelationFile = None
files = [file for file in sorted(os.listdir(folder)) if isARawImage(file)]
@ -36,10 +39,10 @@ for file in tqdm(files, 'File'):
mergedSingleColorChannelImage = mergeSingleColorChannelImagesAccordingToBayerFilter(colorChannels)
if lastMergedSingleColorChannelImage is not None:
correlation = corr(mergedSingleColorChannelImage, lastMergedSingleColorChannelImage)
if highestCorrelation is None or correlation > highestCorrelation:
highestCorrelation = correlation
highestCorrelationFile = file
if extremeCorrelation is None or correlation < extremeCorrelation:
extremeCorrelation = correlation
extremeCorrelationFile = file
lastMergedSingleColorChannelImage = mergedSingleColorChannelImage
print(f'{highestCorrelationFile} (and previous file) have the highest correlation with a correlation of {highestCorrelation}')
print(f'{extremeCorrelationFile} (and previous file) have the lowest correlation with a correlation of {extremeCorrelation}')