diff --git a/src/helpers/statistics.py b/src/helpers/statistics.py index c92e061..176670e 100644 --- a/src/helpers/statistics.py +++ b/src/helpers/statistics.py @@ -1,4 +1,5 @@ import numpy as np +import math def imgStats(img): mean = np.zeros(3) @@ -6,4 +7,20 @@ def imgStats(img): for i in range(img.shape[2]): mean[i] = np.mean(img[:, :, i]) std[i] = np.std(img[:, :, i]) - return mean, std \ No newline at end of file + return mean, std + +def calcNormalFunc(mean, sd, len): + f = np.zeros(len, dtype=np.longdouble) + + # calculate PDF + for x in range(len): + exp = (-(x - mean) ** 2)/(2 * sd ** 2) + f[x] = 1 / math.sqrt(2 * np.pi * sd** 20 ) * (math.exp(exp)) + + # normalize PDF + max = np.amax(f) + min = np.amin(f) + for x in range(len): + f[x] = (f[x] - min) / (max - min) + + return f \ No newline at end of file