@@ -127,7 +127,6 @@ cdef _proesmans(float64 [:, :, :] R, float64 [:, :, :, :] V, intp num_iter,
127127
128128 xd = x + v_avg_1
129129 yd = y + v_avg_2
130-
131130 if xd >= 0 and xd < n - 1 and yd >= 0 and yd < m - 1 :
132131 It = (_linear_interpolate(R_j_2, xd, yd) - \
133132 R_j_1[y, x]) * _INTENSITY_SCALE
@@ -158,7 +157,7 @@ cdef float64 _compute_laplacian(float64 [:, :] gi, float64 [:, :, :] Vi, intp x,
158157 gi[y, x+ 1 ] + gi[y+ 1 , x]) / 6.0 + \
159158 (gi[y- 1 , x- 1 ] + gi[y- 1 , x+ 1 ] + \
160159 gi[y+ 1 , x- 1 ] + gi[y+ 1 , x+ 1 ]) / 12.0
161-
160+
162161 if sumWeights > 1e-8 :
163162 v = (gi[y- 1 , x] * Vi[j, y- 1 , x] + gi[y, x- 1 ] * Vi[j, y, x- 1 ] + \
164163 gi[y, x+ 1 ] * Vi[j, y, x+ 1 ] + gi[y+ 1 , x] * Vi[j, y+ 1 , x]) / 6.0 + \
@@ -167,9 +166,7 @@ cdef float64 _compute_laplacian(float64 [:, :] gi, float64 [:, :, :] Vi, intp x,
167166
168167 return v / sumWeights
169168 else :
170- # use the previous value if the weight sum is too small to give accurate
171- # results
172- return Vi[j, y, x]
169+ return 0.0
173170
174171@ cython.boundscheck (False )
175172@ cython.wraparound (False )
@@ -226,16 +223,20 @@ cdef void _compute_consistency_maps(float64 [:, :, :, :] V,
226223
227224 if c_count > 0 :
228225 K = 0.9 * c_sum / c_count
226+ else :
227+ K = 0.0
229228
230- if K > 0.0 :
231- # for y in prange(m, schedule='guided', nogil=True):
232- for y in range (m):
233- for x in range (n):
229+ # for y in prange(m, schedule='guided', nogil=True):
230+ for y in range (m):
231+ for x in range (n):
232+ if K > 1e-8 :
233+ if GAMMA[i, y, x] >= 0.0 :
234234 g = GAMMA[i, y, x]
235- if g >= 0.0 :
236- GAMMA[i, y, x] = 1.0 / (1.0 + (g / K) * (g / K))
237- else :
238- GAMMA[i, y, x] = 0.0
235+ GAMMA[i, y, x] = 1.0 / (1.0 + (g / K) * (g / K))
236+ else :
237+ GAMMA[i, y, x] = 1.0
238+ else :
239+ GAMMA[i, y, x] = 1.0
239240
240241cdef np.ndarray[float64, ndim= 3 ] _compute_gradients(float64 [:, :] I):
241242 # use 3x3 Sobel kernels for computing partial derivatives
0 commit comments