#66: Stop execution if Pearson correlation is negative
This commit is contained in:
parent
60a9dfe89c
commit
f719ff767a
@ -26,7 +26,7 @@ match DISTANCE:
|
||||
from rms_diff import rmsDiffNumpy
|
||||
case PEARSON_CORRELATION:
|
||||
import scipy
|
||||
from utils import getPearsonCorrelation
|
||||
from utils import getPearsonCorrelationDistance
|
||||
|
||||
setting = ','.join([escapeFilePath(imageCameraFolder) for imageCameraFolder in IMAGES_CAMERAS_FOLDER]) + f'_{DENOISER}'
|
||||
|
||||
@ -194,7 +194,7 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
|
||||
case ROOT_MEAN_SQUARE:
|
||||
distance = rmsDiffNumpy(cameraTestingImageNoise, camerasIterativeMean[camera].mean)
|
||||
case PEARSON_CORRELATION:
|
||||
distance = getPearsonCorrelation(cameraTestingImagesNoise[actualCamera][cameraTestingImageIndex], camerasIterativeMean[camera].mean)
|
||||
distance = getPearsonCorrelationDistance(cameraTestingImagesNoise[actualCamera][cameraTestingImageIndex], camerasIterativeMean[camera].mean)
|
||||
print(f'{cameraTrainingImageIndex=} {cameraTestingImageIndex=} {camera=} {actualCamera=} {distance=}')
|
||||
if minimalDistance is None or distance < minimalDistance:
|
||||
minimalDistance = distance
|
||||
|
@ -20,7 +20,7 @@ match DISTANCE:
|
||||
from rms_diff import rmsDiffNumpy
|
||||
case PEARSON_CORRELATION:
|
||||
import scipy
|
||||
from utils import getPearsonCorrelation
|
||||
from utils import getPearsonCorrelationDistance
|
||||
|
||||
setting = escapeFilePath(IMAGES_FOLDER) + f'_{DENOISER}'
|
||||
|
||||
@ -67,7 +67,7 @@ for computeExtremes in tqdm(([True] if minColor is None or maxColor is None else
|
||||
case ROOT_MEAN_SQUARE:
|
||||
distance = rmsDiffNumpy(firstImage, secondImage)
|
||||
case PEARSON_CORRELATION:
|
||||
distance = getPearsonCorrelation(firstImage, secondImage)
|
||||
distance = getPearsonCorrelationDistance(firstImage, secondImage)
|
||||
distances += [distance]
|
||||
|
||||
for subgroupIndex in range(NUMBER_OF_SUBGROUPS):
|
||||
|
@ -43,8 +43,12 @@ class Distance(Enum)
|
||||
def getEndUserName(self):
|
||||
return self.name.replace('_', '').title()
|
||||
|
||||
def getPearsonCorrelation(firstImage, secondImage):
|
||||
return abs(scipy.stats.pearsonr(firstImage.flatten(), secondImage.flatten()).statistic - 1)
|
||||
def getPearsonCorrelationDistance(firstImage, secondImage):
|
||||
pearsonCorrelation = scipy.stats.pearsonr(firstImage.flatten(), secondImage.flatten()).statistic
|
||||
if pearsonCorrelation < 0:
|
||||
print('Negative Pearson correlation, investigate further!')
|
||||
exit(1)
|
||||
return abs(pearsonCorrelation - 1)
|
||||
|
||||
# Source: https://stackoverflow.com/a/43346070
|
||||
def getGaussianKernel(size, sigma):
|
||||
|
Loading…
Reference in New Issue
Block a user