Commit 358c45fbff1583815fd1ca71740578d601278fea
1 parent
b26289dd
Exists in
master
and in
40 other branches
ENH: Fixed problems in the Windows version (watershed).
Showing
1 changed file
with
8 additions
and
27 deletions
Show diff stats
invesalius/data/styles.py
| ... | ... | @@ -38,6 +38,8 @@ from scipy.ndimage import watershed_ift, generate_binary_structure |
| 38 | 38 | from skimage.morphology import watershed |
| 39 | 39 | from skimage import filter |
| 40 | 40 | |
| 41 | +import watershed_process | |
| 42 | + | |
| 41 | 43 | import utils |
| 42 | 44 | |
| 43 | 45 | ORIENTATIONS = { |
| ... | ... | @@ -1244,8 +1246,8 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): |
| 1244 | 1246 | tmp_mask = np.memmap(tfile, shape=mask.shape, dtype=mask.dtype, |
| 1245 | 1247 | mode='w+') |
| 1246 | 1248 | q = multiprocessing.Queue() |
| 1247 | - p = multiprocessing.Process(target=do_watershed, args=(image, | |
| 1248 | - markers, tmp_mask, bstruct, | |
| 1249 | + p = multiprocessing.Process(target=watershed_process.do_watershed, args=(image, | |
| 1250 | + markers, tfile, tmp_mask.shape, bstruct, | |
| 1249 | 1251 | self.config.algorithm, |
| 1250 | 1252 | self.config.mg_size, |
| 1251 | 1253 | self.config.use_ww_wl, wl, ww, q)) |
| ... | ... | @@ -1292,6 +1294,9 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): |
| 1292 | 1294 | ##tmp_image = ndimage.morphological_gradient((image - image.min()).astype('uint16'), self.config.mg_size) |
| 1293 | 1295 | #tmp_mask = watershed_ift(tmp_image, markers.astype('int8'), bstruct) |
| 1294 | 1296 | |
| 1297 | + print "mask.max >>>", tmp_mask.max() | |
| 1298 | + print "mask.min >>>", tmp_mask.min() | |
| 1299 | + | |
| 1295 | 1300 | if self.viewer.overwrite_mask: |
| 1296 | 1301 | mask[:] = 0 |
| 1297 | 1302 | mask[tmp_mask == 1] = 253 |
| ... | ... | @@ -1309,31 +1314,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): |
| 1309 | 1314 | Publisher.sendMessage('Reload actual slice') |
| 1310 | 1315 | |
| 1311 | 1316 | |
| 1312 | -def do_watershed(image, markers, mask, bstruct, algorithm, mg_size, use_ww_wl, wl, ww, q): | |
| 1313 | - if use_ww_wl: | |
| 1314 | - if algorithm == 'Watershed': | |
| 1315 | - tmp_image = ndimage.morphological_gradient( | |
| 1316 | - get_LUT_value(image, ww, wl).astype('uint16'), | |
| 1317 | - mg_size) | |
| 1318 | - tmp_mask = watershed(tmp_image, markers.astype('int16'), bstruct) | |
| 1319 | - else: | |
| 1320 | - tmp_image = get_LUT_value(image, ww, wl).astype('uint16') | |
| 1321 | - #tmp_image = ndimage.gaussian_filter(tmp_image, self.config.mg_size) | |
| 1322 | - #tmp_image = ndimage.morphological_gradient( | |
| 1323 | - #get_LUT_value(image, ww, wl).astype('uint16'), | |
| 1324 | - #self.config.mg_size) | |
| 1325 | - tmp_mask = watershed_ift(tmp_image, markers.astype('int16'), bstruct) | |
| 1326 | - else: | |
| 1327 | - if algorithm == 'Watershed': | |
| 1328 | - tmp_image = ndimage.morphological_gradient((image - image.min()).astype('uint16'), mg_size) | |
| 1329 | - tmp_mask = watershed(tmp_image, markers.astype('int16'), bstruct) | |
| 1330 | - else: | |
| 1331 | - tmp_image = (image - image.min()).astype('uint16') | |
| 1332 | - #tmp_image = ndimage.gaussian_filter(tmp_image, self.config.mg_size) | |
| 1333 | - #tmp_image = ndimage.morphological_gradient((image - image.min()).astype('uint16'), self.config.mg_size) | |
| 1334 | - tmp_mask = watershed_ift(tmp_image, markers.astype('int8'), bstruct) | |
| 1335 | - mask[:] = tmp_mask | |
| 1336 | - q.put(1) | |
| 1317 | + | |
| 1337 | 1318 | |
| 1338 | 1319 | |
| 1339 | 1320 | ... | ... |