Commit 14b9edd1db66b1f79303208a13f5a61df5167547
1 parent
5ac92d4f
Exists in
smoothing_bin_pll
Some testings
Showing
1 changed file
with
11 additions
and
3 deletions
Show diff stats
invesalius/data/smooth_cy.pyx
@@ -90,7 +90,11 @@ cdef DTYPEF64_t calculate_H(DTYPEF64_t[:, :, :] I, int z, int y, int x) nogil: | @@ -90,7 +90,11 @@ cdef DTYPEF64_t calculate_H(DTYPEF64_t[:, :, :] I, int z, int y, int x) nogil: | ||
90 | + fx*fz*fxz + fy*fz*fyz)) \ | 90 | + fx*fz*fxz + fy*fz*fyz)) \ |
91 | / (fx*fx + fy*fy + fz*fz) | 91 | / (fx*fx + fy*fy + fz*fz) |
92 | else: | 92 | else: |
93 | - H = 0.0 | 93 | + |
94 | + H = ((fy*fy + fz*fz)*fxx + (fx*fx + fz*fz)*fyy \ | ||
95 | + + (fx*fx + fy*fy)*fzz - 2*(fx*fy*fxy \ | ||
96 | + + fx*fz*fxz + fy*fz*fyz)) \ | ||
97 | + / (0.000001) | ||
94 | 98 | ||
95 | return H | 99 | return H |
96 | 100 | ||
@@ -135,6 +139,8 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, | @@ -135,6 +139,8 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, | ||
135 | 139 | ||
136 | del _mask | 140 | del _mask |
137 | 141 | ||
142 | + # mask[:] = mask - image | ||
143 | + | ||
138 | cdef int dz = image.shape[0] | 144 | cdef int dz = image.shape[0] |
139 | cdef int dy = image.shape[1] | 145 | cdef int dy = image.shape[1] |
140 | cdef int dx = image.shape[2] | 146 | cdef int dx = image.shape[2] |
@@ -164,12 +170,12 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, | @@ -164,12 +170,12 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, | ||
164 | 170 | ||
165 | if image[z, y, x]: | 171 | if image[z, y, x]: |
166 | if v < 0: | 172 | if v < 0: |
167 | - out[z, y, x] = 0.0 | 173 | + out[z, y, x] = 0.00001 |
168 | else: | 174 | else: |
169 | out[z, y, x] = v | 175 | out[z, y, x] = v |
170 | else: | 176 | else: |
171 | if v > 0: | 177 | if v > 0: |
172 | - out[z, y, x] = 0.0 | 178 | + out[z, y, x] = -0.00001 |
173 | else: | 179 | else: |
174 | out[z, y, x] = v | 180 | out[z, y, x] = v |
175 | 181 | ||
@@ -180,3 +186,5 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, | @@ -180,3 +186,5 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, | ||
180 | 186 | ||
181 | if cn <= E: | 187 | if cn <= E: |
182 | break | 188 | break |
189 | + | ||
190 | + return mask |