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 | 90 | + fx*fz*fxz + fy*fz*fyz)) \ |
91 | 91 | / (fx*fx + fy*fy + fz*fz) |
92 | 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 | 99 | return H |
96 | 100 | |
... | ... | @@ -135,6 +139,8 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, |
135 | 139 | |
136 | 140 | del _mask |
137 | 141 | |
142 | + # mask[:] = mask - image | |
143 | + | |
138 | 144 | cdef int dz = image.shape[0] |
139 | 145 | cdef int dy = image.shape[1] |
140 | 146 | cdef int dx = image.shape[2] |
... | ... | @@ -164,12 +170,12 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, |
164 | 170 | |
165 | 171 | if image[z, y, x]: |
166 | 172 | if v < 0: |
167 | - out[z, y, x] = 0.0 | |
173 | + out[z, y, x] = 0.00001 | |
168 | 174 | else: |
169 | 175 | out[z, y, x] = v |
170 | 176 | else: |
171 | 177 | if v > 0: |
172 | - out[z, y, x] = 0.0 | |
178 | + out[z, y, x] = -0.00001 | |
173 | 179 | else: |
174 | 180 | out[z, y, x] = v |
175 | 181 | |
... | ... | @@ -180,3 +186,5 @@ def smooth(np.ndarray[DTYPE8_t, ndim=3] image, |
180 | 186 | |
181 | 187 | if cn <= E: |
182 | 188 | break |
189 | + | |
190 | + return mask | ... | ... |