Commit 9a65a3410352e6637ff61fc6c5172b7ea6b63056

Authored by fabioaz
1 parent 553830f4

FIX: Workaround to solve problem when using multiprocessing under Windows.

Showing 1 changed file with 24 additions and 2 deletions   Show diff stats
invesalius/data/surface_process.py
@@ -7,10 +7,31 @@ import vtk @@ -7,10 +7,31 @@ import vtk
7 7
8 import i18n 8 import i18n
9 import converters 9 import converters
10 -import imagedata_utils as iu 10 +# import imagedata_utils as iu
11 11
12 from scipy import ndimage 12 from scipy import ndimage
13 13
  14 +# TODO: Code duplicated from file {imagedata_utils.py}.
  15 +def ResampleImage3D(imagedata, value):
  16 + """
  17 + Resample vtkImageData matrix.
  18 + """
  19 + spacing = imagedata.GetSpacing()
  20 + extent = imagedata.GetExtent()
  21 + size = imagedata.GetDimensions()
  22 +
  23 + width = float(size[0])
  24 + height = float(size[1]/value)
  25 +
  26 + resolution = (height/(extent[1]-extent[0])+1)*spacing[1]
  27 +
  28 + resample = vtk.vtkImageResample()
  29 + resample.SetInput(imagedata)
  30 + resample.SetAxisMagnificationFactor(0, resolution)
  31 + resample.SetAxisMagnificationFactor(1, resolution)
  32 +
  33 + return resample.GetOutput()
  34 +
14 class SurfaceProcess(multiprocessing.Process): 35 class SurfaceProcess(multiprocessing.Process):
15 36
16 def __init__(self, pipe, filename, shape, dtype, mask_filename, 37 def __init__(self, pipe, filename, shape, dtype, mask_filename,
@@ -100,7 +121,8 @@ class SurfaceProcess(multiprocessing.Process): @@ -100,7 +121,8 @@ class SurfaceProcess(multiprocessing.Process):
100 del a_image 121 del a_image
101 122
102 if self.imagedata_resolution: 123 if self.imagedata_resolution:
103 - image = iu.ResampleImage3D(image, self.imagedata_resolution) 124 + # image = iu.ResampleImage3D(image, self.imagedata_resolution)
  125 + image = ResampleImage3D(image, self.imagedata_resolution)
104 126
105 flip = vtk.vtkImageFlip() 127 flip = vtk.vtkImageFlip()
106 flip.SetInput(image) 128 flip.SetInput(image)