rename n_se_n to num_se_n etc, removed commented code

This commit is contained in:
Olivier Debeir
2012-10-12 17:47:51 +02:00
parent 32d40f80ee
commit 894cb13f50
6 changed files with 112 additions and 369 deletions
+22 -22
View File
@@ -93,7 +93,7 @@ char shift_x, char shift_y,int bitdepth):
cdef int max_se = srows*scols
# number of element in each attack border
cdef int n_se_n, n_se_s, n_se_e, n_se_w
cdef int num_se_n, num_se_s, num_se_e, num_se_w
# the current local histogram distribution
cdef int* histo = <int*>malloc(maxbin * sizeof(int))
@@ -126,26 +126,26 @@ char shift_x, char shift_y,int bitdepth):
t = np.vstack((np.zeros((1,selem.shape[1])),selem))
t_n = np.diff(t,axis=0)==1
n_se_n = n_se_s = n_se_e = n_se_w = 0
num_se_n = num_se_s = num_se_e = num_se_w = 0
for r in range(srows):
for c in range(scols):
if t_e[r,c]:
se_e_r[n_se_e] = r - centre_r
se_e_c[n_se_e] = c - centre_c
n_se_e += 1
se_e_r[num_se_e] = r - centre_r
se_e_c[num_se_e] = c - centre_c
num_se_e += 1
if t_w[r,c]:
se_w_r[n_se_w] = r - centre_r
se_w_c[n_se_w] = c - centre_c
n_se_w += 1
se_w_r[num_se_w] = r - centre_r
se_w_c[num_se_w] = c - centre_c
num_se_w += 1
if t_n[r,c]:
se_n_r[n_se_n] = r - centre_r
se_n_c[n_se_n] = c - centre_c
n_se_n += 1
se_n_r[num_se_n] = r - centre_r
se_n_c[num_se_n] = c - centre_c
num_se_n += 1
if t_s[r,c]:
se_s_r[n_se_s] = r - centre_r
se_s_c[n_se_s] = c - centre_c
n_se_s += 1
se_s_r[num_se_s] = r - centre_r
se_s_c[num_se_s] = c - centre_c
num_se_s += 1
# initial population and histogram
for i in range(maxbin):
@@ -175,14 +175,14 @@ char shift_x, char shift_y,int bitdepth):
for even_row in range(0,rows,2):
# ---> west to east
for c in range(1,cols):
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c - 1
if emask_data[rr * ecols + cc]:
@@ -200,14 +200,14 @@ char shift_x, char shift_y,int bitdepth):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
@@ -222,14 +222,14 @@ char shift_x, char shift_y,int bitdepth):
# ---> east to west
for c in range(cols-2,-1,-1):
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c + 1
if emask_data[rr * ecols + cc]:
@@ -247,14 +247,14 @@ char shift_x, char shift_y,int bitdepth):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
+22 -22
View File
@@ -94,7 +94,7 @@ char shift_x, char shift_y,int bitdepth, int s0, int s1):
cdef int max_se = srows*scols
# number of element in each attack border
cdef int n_se_n, n_se_s, n_se_e, n_se_w
cdef int num_se_n, num_se_s, num_se_e, num_se_w
# the current local histogram distribution
cdef int* histo = <int*>malloc(maxbin * sizeof(int))
@@ -127,26 +127,26 @@ char shift_x, char shift_y,int bitdepth, int s0, int s1):
t = np.vstack((np.zeros((1,selem.shape[1])),selem))
t_n = np.diff(t,axis=0)==1
n_se_n = n_se_s = n_se_e = n_se_w = 0
num_se_n = num_se_s = num_se_e = num_se_w = 0
for r in range(srows):
for c in range(scols):
if t_e[r,c]:
se_e_r[n_se_e] = r - centre_r
se_e_c[n_se_e] = c - centre_c
n_se_e += 1
se_e_r[num_se_e] = r - centre_r
se_e_c[num_se_e] = c - centre_c
num_se_e += 1
if t_w[r,c]:
se_w_r[n_se_w] = r - centre_r
se_w_c[n_se_w] = c - centre_c
n_se_w += 1
se_w_r[num_se_w] = r - centre_r
se_w_c[num_se_w] = c - centre_c
num_se_w += 1
if t_n[r,c]:
se_n_r[n_se_n] = r - centre_r
se_n_c[n_se_n] = c - centre_c
n_se_n += 1
se_n_r[num_se_n] = r - centre_r
se_n_c[num_se_n] = c - centre_c
num_se_n += 1
if t_s[r,c]:
se_s_r[n_se_s] = r - centre_r
se_s_c[n_se_s] = c - centre_c
n_se_s += 1
se_s_r[num_se_s] = r - centre_r
se_s_c[num_se_s] = c - centre_c
num_se_s += 1
# initial population and histogram
for i in range(maxbin):
@@ -176,14 +176,14 @@ char shift_x, char shift_y,int bitdepth, int s0, int s1):
for even_row in range(0,rows,2):
# ---> west to east
for c in range(1,cols):
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c - 1
if emask_data[rr * ecols + cc]:
@@ -201,14 +201,14 @@ char shift_x, char shift_y,int bitdepth, int s0, int s1):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
@@ -223,14 +223,14 @@ char shift_x, char shift_y,int bitdepth, int s0, int s1):
# ---> east to west
for c in range(cols-2,-1,-1):
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c + 1
if emask_data[rr * ecols + cc]:
@@ -248,14 +248,14 @@ char shift_x, char shift_y,int bitdepth, int s0, int s1):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
+22 -22
View File
@@ -90,7 +90,7 @@ char shift_x, char shift_y,int bitdepth, float p0, float p1):
cdef int max_se = srows*scols
# number of element in each attack border
cdef int n_se_n, n_se_s, n_se_e, n_se_w
cdef int num_se_n, num_se_s, num_se_e, num_se_w
# the current local histogram distribution
cdef int* histo = <int*>malloc(maxbin * sizeof(int))
@@ -123,26 +123,26 @@ char shift_x, char shift_y,int bitdepth, float p0, float p1):
t = np.vstack((np.zeros((1,selem.shape[1])),selem))
t_n = np.diff(t,axis=0)==1
n_se_n = n_se_s = n_se_e = n_se_w = 0
num_se_n = num_se_s = num_se_e = num_se_w = 0
for r in range(srows):
for c in range(scols):
if t_e[r,c]:
se_e_r[n_se_e] = r - centre_r
se_e_c[n_se_e] = c - centre_c
n_se_e += 1
se_e_r[num_se_e] = r - centre_r
se_e_c[num_se_e] = c - centre_c
num_se_e += 1
if t_w[r,c]:
se_w_r[n_se_w] = r - centre_r
se_w_c[n_se_w] = c - centre_c
n_se_w += 1
se_w_r[num_se_w] = r - centre_r
se_w_c[num_se_w] = c - centre_c
num_se_w += 1
if t_n[r,c]:
se_n_r[n_se_n] = r - centre_r
se_n_c[n_se_n] = c - centre_c
n_se_n += 1
se_n_r[num_se_n] = r - centre_r
se_n_c[num_se_n] = c - centre_c
num_se_n += 1
if t_s[r,c]:
se_s_r[n_se_s] = r - centre_r
se_s_c[n_se_s] = c - centre_c
n_se_s += 1
se_s_r[num_se_s] = r - centre_r
se_s_c[num_se_s] = c - centre_c
num_se_s += 1
# initial population and histogram
for i in range(maxbin):
@@ -172,14 +172,14 @@ char shift_x, char shift_y,int bitdepth, float p0, float p1):
for even_row in range(0,rows,2):
# ---> west to east
for c in range(1,cols):
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c - 1
if emask_data[rr * ecols + cc]:
@@ -197,14 +197,14 @@ char shift_x, char shift_y,int bitdepth, float p0, float p1):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
@@ -219,14 +219,14 @@ char shift_x, char shift_y,int bitdepth, float p0, float p1):
# ---> east to west
for c in range(cols-2,-1,-1):
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c + 1
if emask_data[rr * ecols + cc]:
@@ -244,14 +244,14 @@ char shift_x, char shift_y,int bitdepth, float p0, float p1):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
+22 -22
View File
@@ -83,7 +83,7 @@ char shift_x, char shift_y):
cdef int max_se = srows*scols
# number of element in each attack border
cdef int n_se_n, n_se_s, n_se_e, n_se_w
cdef int num_se_n, num_se_s, num_se_e, num_se_w
# the current local histogram distribution
cdef int* histo = <int*>malloc(256 * sizeof(int))
@@ -116,26 +116,26 @@ char shift_x, char shift_y):
t = np.vstack((np.zeros((1,selem.shape[1])),selem))
t_n = np.diff(t,axis=0)==1
n_se_n = n_se_s = n_se_e = n_se_w = 0
num_se_n = num_se_s = num_se_e = num_se_w = 0
for r in range(srows):
for c in range(scols):
if t_e[r,c]:
se_e_r[n_se_e] = r - centre_r
se_e_c[n_se_e] = c - centre_c
n_se_e += 1
se_e_r[num_se_e] = r - centre_r
se_e_c[num_se_e] = c - centre_c
num_se_e += 1
if t_w[r,c]:
se_w_r[n_se_w] = r - centre_r
se_w_c[n_se_w] = c - centre_c
n_se_w += 1
se_w_r[num_se_w] = r - centre_r
se_w_c[num_se_w] = c - centre_c
num_se_w += 1
if t_n[r,c]:
se_n_r[n_se_n] = r - centre_r
se_n_c[n_se_n] = c - centre_c
n_se_n += 1
se_n_r[num_se_n] = r - centre_r
se_n_c[num_se_n] = c - centre_c
num_se_n += 1
if t_s[r,c]:
se_s_r[n_se_s] = r - centre_r
se_s_c[n_se_s] = c - centre_c
n_se_s += 1
se_s_r[num_se_s] = r - centre_r
se_s_c[num_se_s] = c - centre_c
num_se_s += 1
# initial population and histogram
for i in range(256):
@@ -164,14 +164,14 @@ char shift_x, char shift_y):
for even_row in range(0,rows,2):
# ---> west to east
for c in range(1,cols):
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c - 1
if emask_data[rr * ecols + cc]:
@@ -188,14 +188,14 @@ char shift_x, char shift_y):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
@@ -209,14 +209,14 @@ char shift_x, char shift_y):
# ---> east to west
for c in range(cols-2,-1,-1):
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c + 1
if emask_data[rr * ecols + cc]:
@@ -233,14 +233,14 @@ char shift_x, char shift_y):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
+22 -22
View File
@@ -80,7 +80,7 @@ char shift_x, char shift_y, float p0, float p1):
cdef int max_se = srows*scols
# number of element in each attack border
cdef int n_se_n, n_se_s, n_se_e, n_se_w
cdef int num_se_n, num_se_s, num_se_e, num_se_w
# the current local histogram distribution
cdef int* histo = <int*>malloc(256 * sizeof(int))
@@ -113,26 +113,26 @@ char shift_x, char shift_y, float p0, float p1):
t = np.vstack((np.zeros((1,selem.shape[1])),selem))
t_n = np.diff(t,axis=0)==1
n_se_n = n_se_s = n_se_e = n_se_w = 0
num_se_n = num_se_s = num_se_e = num_se_w = 0
for r in range(srows):
for c in range(scols):
if t_e[r,c]:
se_e_r[n_se_e] = r - centre_r
se_e_c[n_se_e] = c - centre_c
n_se_e += 1
se_e_r[num_se_e] = r - centre_r
se_e_c[num_se_e] = c - centre_c
num_se_e += 1
if t_w[r,c]:
se_w_r[n_se_w] = r - centre_r
se_w_c[n_se_w] = c - centre_c
n_se_w += 1
se_w_r[num_se_w] = r - centre_r
se_w_c[num_se_w] = c - centre_c
num_se_w += 1
if t_n[r,c]:
se_n_r[n_se_n] = r - centre_r
se_n_c[n_se_n] = c - centre_c
n_se_n += 1
se_n_r[num_se_n] = r - centre_r
se_n_c[num_se_n] = c - centre_c
num_se_n += 1
if t_s[r,c]:
se_s_r[n_se_s] = r - centre_r
se_s_c[n_se_s] = c - centre_c
n_se_s += 1
se_s_r[num_se_s] = r - centre_r
se_s_c[num_se_s] = c - centre_c
num_se_s += 1
# initial population and histogram
for i in range(256):
@@ -161,14 +161,14 @@ char shift_x, char shift_y, float p0, float p1):
for even_row in range(0,rows,2):
# ---> west to east
for c in range(1,cols):
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c - 1
if emask_data[rr * ecols + cc]:
@@ -185,14 +185,14 @@ char shift_x, char shift_y, float p0, float p1):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
@@ -206,14 +206,14 @@ char shift_x, char shift_y, float p0, float p1):
# ---> east to west
for c in range(cols-2,-1,-1):
for s in range(n_se_w):
for s in range(num_se_w):
rr = r + se_w_r[s] + centre_r
cc = c + se_w_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_e):
for s in range(num_se_e):
rr = r + se_e_r[s] + centre_r
cc = c + se_e_c[s] + centre_c + 1
if emask_data[rr * ecols + cc]:
@@ -230,14 +230,14 @@ char shift_x, char shift_y, float p0, float p1):
break
# ---> north to south
for s in range(n_se_s):
for s in range(num_se_s):
rr = r + se_s_r[s] + centre_r
cc = c + se_s_c[s] + centre_c
if emask_data[rr * ecols + cc]:
value = eimage_data[rr * ecols + cc]
histo[value] += 1
pop += 1.
for s in range(n_se_n):
for s in range(num_se_n):
rr = r + se_n_r[s] + centre_r - 1
cc = c + se_n_c[s] + centre_c
if emask_data[rr * ecols + cc]:
+2 -259
View File
@@ -21,73 +21,6 @@ from _core16b cimport _core16b
# kernels uint16 take extra parameter for defining the bitdepth
# -----------------------------------------------------------------
#cdef inline np.uint16_t kernel_autolevel(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i,imin,imax,delta
#
# if pop:
# for i in range(maxbin-1,-1,-1):
# if histo[i]:
# imax = i
# break
# for i in range(maxbin):
# if histo[i]:
# imin = i
# break
# delta = imax-imin
# if delta>0:
# return <np.uint16_t>(maxbin*1.*(g-imin)/delta)
# else:
# return <np.uint16_t>(imax-imin)
#
#cdef inline np.uint16_t kernel_bottomhat(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
#
# for i in range(maxbin):
# if histo[i]:
# break
#
# return <np.uint16_t>(g-i)
#
#
#cdef inline np.uint16_t kernel_egalise(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
# cdef float sum = 0.
#
# if pop:
# for i in range(maxbin):
# sum += histo[i]
# if i>=g:
# break
#
# return <np.uint16_t>((maxbin*1.*sum)/pop)
# else:
# return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_gradient(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i,imin,imax
#
# if pop:
# for i in range(maxbin-1,-1,-1):
# if histo[i]:
# imax = i
# break
# for i in range(maxbin):
# if histo[i]:
# imin = i
# break
# return <np.uint16_t>(imax-imin)
# else:
# return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_maximum(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
#
# if pop:
# for i in range(maxbin-1,-1,-1):
# if histo[i]:
# return <np.uint16_t>(i)
#
# return <np.uint16_t>(0)
cdef inline np.uint16_t kernel_mean(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, int s0, int s1):
cdef int i,bilat_pop=0
@@ -105,71 +38,7 @@ cdef inline np.uint16_t kernel_mean(int* histo, float pop, np.uint16_t g,int bit
else:
return <np.uint16_t>(0)
#cdef inline np.uint16_t kernel_meansubstraction(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
# cdef float mean = 0.
#
# if pop:
# for i in range(maxbin):
# mean += histo[i]*i
# return <np.uint16_t>((g-mean/pop)/2.+midbin)
# else:
# return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_median(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
# cdef float sum = pop/2.0
#
# if pop:
# for i in range(maxbin):
# if histo[i]:
# sum -= histo[i]
# if sum<0:
# return <np.uint16_t>(i)
#
# return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_minimum(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
#
# if pop:
# for i in range(maxbin):
# if histo[i]:
# return <np.uint16_t>(i)
#
# return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_modal(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int hmax=0,imax=0
#
# if pop:
# for i in range(maxbin):
# if histo[i]>hmax:
# hmax = histo[i]
# imax = i
# return <np.uint16_t>(imax)
#
# return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_morph_contr_enh(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i,imin,imax
#
# if pop:
# for i in range(maxbin-1,-1,-1):
# if histo[i]:
# imax = i
# break
# for i in range(maxbin):
# if histo[i]:
# imin = i
# break
# if imax-g < g-imin:
# return <np.uint16_t>(imax)
# else:
# return <np.uint16_t>(imin)
# else:
# return <np.uint16_t>(0)
#
cdef inline np.uint16_t kernel_pop(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, int s0, int s1):
cdef int i,bilat_pop=0
@@ -181,75 +50,10 @@ cdef inline np.uint16_t kernel_pop(int* histo, float pop, np.uint16_t g,int bitd
else:
return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_threshold(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
# cdef float mean = 0.
#
# if pop:
# for i in range(maxbin):
# mean += histo[i]*i
# return <np.uint16_t>(g>(mean/pop))
# else:
# return <np.uint16_t>(0)
#
#cdef inline np.uint16_t kernel_tophat(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin):
# cdef int i
#
# for i in range(maxbin-1,-1,-1):
# if histo[i]:
# break
#
# return <np.uint16_t>(i-g)
# -----------------------------------------------------------------
# python wrappers
# -----------------------------------------------------------------
#def autolevel(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """bottom hat
# """
# return rank16b(kernel_autolevel,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def bottomhat(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """bottom hat
# """
# return rank16b(kernel_bottomhat,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def egalise(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """local egalisation of the gray level
# """
# return rank16b(kernel_egalise,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def gradient(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """local maximum - local minimum gray level
# """
# return rank16b(kernel_gradient,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def maximum(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """local maximum gray level
# """
# return rank16b(kernel_maximum,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
def mean(np.ndarray[np.uint16_t, ndim=2] image,
np.ndarray[np.uint8_t, ndim=2] selem,
np.ndarray[np.uint8_t, ndim=2] mask=None,
@@ -259,51 +63,7 @@ def mean(np.ndarray[np.uint16_t, ndim=2] image,
"""
return _core16b(kernel_mean,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#def meansubstraction(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """(g - average gray level)/2+midbin (clipped on uint8)
# """
# return rank16b(kernel_meansubstraction,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def median(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """local median
# """
# return rank16b(kernel_median,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def minimum(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """local minimum gray level
# """
# return rank16b(kernel_minimum,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """morphological contrast enhancement
# """
# return rank16b(kernel_morph_contr_enh,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def modal(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """local mode
# """
# return rank16b(kernel_modal,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
def pop(np.ndarray[np.uint16_t, ndim=2] image,
np.ndarray[np.uint8_t, ndim=2] selem,
np.ndarray[np.uint8_t, ndim=2] mask=None,
@@ -313,20 +73,3 @@ def pop(np.ndarray[np.uint16_t, ndim=2] image,
"""
return _core16b(kernel_pop,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#def threshold(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """returns maxbin-1 if gray level higher than local mean, 0 else
# """
# return rank16b(kernel_threshold,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)
#
#def tophat(np.ndarray[np.uint16_t, ndim=2] image,
# np.ndarray[np.uint8_t, ndim=2] selem,
# np.ndarray[np.uint8_t, ndim=2] mask=None,
# np.ndarray[np.uint16_t, ndim=2] out=None,
# char shift_x=0, char shift_y=0, int bitdepth=8, int s0=1, int s1=1):
# """top hat
# """
# return rank16b(kernel_tophat,image,selem,mask,out,shift_x,shift_y,bitdepth,s0,s1)