Compare commits

..

No commits in common. "6a2958a68b1f90c8ca974179022c58c4d3696dd1" and "89001d47a0a0d15ea068e1b0fdaffcc329599a61" have entirely different histories.

2 changed files with 1 additions and 55 deletions

View File

@ -1,37 +0,0 @@
import numpy as np
import matplotlib.pyplot as plt
import math
mean = 125
sd = 20
N = 255
f = np.zeros(N, dtype=np.longdouble)
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
f = calcNormalFunc(mean, sd, N)
plt.title("PDF: $\mu = %d$, $\sigma = %d$"%(mean, sd))
plt.plot(f)
plt.grid()
plt.xlim(0, 255)
plt.ylim(0, 1.05)
plt.show()
print("Score at 1 sigma: %f"%f[sd+mean])
print("Score at 2 sigma: %f"%f[2*sd+mean])
print("Score at 3 sigma: %f"%f[3*sd+mean])

View File

@ -1,5 +1,4 @@
import numpy as np
import math
def imgStats(img):
mean = np.zeros(3)
@ -7,20 +6,4 @@ 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
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
return mean, std