text
stringlengths 1
93.6k
|
|---|
g1 = plip_g(g1)
|
g2 = plip_g(g2)
|
return k * ((g1 - g2) / (k - g2))
|
def plip_cross(g1, g2, gamma):
|
g1 = plip_g(g1)
|
g2 = plip_g(g2)
|
return g1 + g2 - ((g1 * g2) / (gamma))
|
def plip_diag(c, g, gamma):
|
g = plip_g(g)
|
return gamma - (gamma * math.pow((1 - (g / gamma)), c))
|
def plip_multiplication(g1, g2):
|
return plip_phiInverse(plip_phi(g1) * plip_phi(g2))
|
# return plip_phiInverse(plip_phi(plip_g(g1)) * plip_phi(plip_g(g2)))
|
def plip_phiInverse(g):
|
plip_lambda = 1026.0
|
plip_beta = 1.0
|
return plip_lambda * (1 - math.pow(math.exp(-g / plip_lambda), 1 / plip_beta));
|
def plip_phi(g):
|
plip_lambda = 1026.0
|
plip_beta = 1.0
|
return -plip_lambda * math.pow(math.log(1 - g / plip_lambda), plip_beta)
|
def _uiconm(x, window_size):
|
"""
|
Underwater image contrast measure
|
ERROR: type should be string, got " https://github.com/tkrahn108/UIQM/blob/master/src/uiconm.cpp\n"
|
ERROR: type should be string, got " https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=5609219\n"
|
"""
|
plip_lambda = 1026.0
|
plip_gamma = 1026.0
|
plip_beta = 1.0
|
plip_mu = 1026.0
|
plip_k = 1026.0
|
# if 4 blocks, then 2x2...etc.
|
k1 = x.shape[1] // window_size
|
k2 = x.shape[0] // window_size
|
# weight
|
w = -1. / (k1 * k2)
|
blocksize_x = window_size
|
blocksize_y = window_size
|
# make sure image is divisible by window_size - doesn't matter if we cut out some pixels
|
x = x[:blocksize_y * k2, :blocksize_x * k1]
|
# entropy scale - higher helps with randomness
|
alpha = 1
|
val = 0
|
for l in range(k1):
|
for k in range(k2):
|
block = x[k * window_size:window_size * (k + 1), l * window_size:window_size * (l + 1), :]
|
max_ = np.max(block)
|
min_ = np.min(block)
|
top = max_ - min_
|
bot = max_ + min_
|
if math.isnan(top) or math.isnan(bot) or bot == 0.0 or top == 0.0:
|
val += 0.0
|
else:
|
val += alpha * math.pow((top / bot), alpha) * math.log(top / bot)
|
# try: val += plip_multiplication((top/bot),math.log(top/bot))
|
return w * val
|
def getUIQM(x):
|
"""
|
Function to return UIQM to be called from other programs
|
x: image
|
"""
|
x = x.astype(np.float32)
|
### from https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7300447
|
# c1 = 0.4680; c2 = 0.2745; c3 = 0.2576
|
### from https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7300447
|
c1 = 0.0282
|
c2 = 0.2953
|
c3 = 3.5753
|
uicm = _uicm(x)
|
uism = _uism(x)
|
uiconm = _uiconm(x, 8)
|
uiqm = (c1 * uicm) + (c2 * uism) + (c3 * uiconm)
|
return uiqm
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.