Added normalfunc calcs
This commit is contained in:
parent
28a1123bab
commit
6a2958a68b
@ -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
|
||||
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
|
Loading…
Reference in New Issue
Block a user