Commit 9e6e2b60849cc23faa6fec135ab36b97af686474

Authored by Paulo Henrique Junqueira Amorim
1 parent a7d53f56

FIX: Enhace quality of surface on an edited region #141

Showing 1 changed file with 39 additions and 3 deletions   Show diff stats
invesalius/data/imagedata_utils.py
... ... @@ -151,19 +151,55 @@ def BuildEditedImage(imagedata, points):
151 151 points in the editor, it is necessary to generate the
152 152 vtkPolyData via vtkContourFilter
153 153 """
  154 + init_values = None
154 155 for point in points:
155 156 x, y, z = point
156 157 colour = points[point]
157 158 imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour)
158 159 imagedata.Update()
159 160  
  161 + if not(init_values):
  162 + xi = x
  163 + xf = x
  164 + yi = y
  165 + yf = y
  166 + zi = z
  167 + zf = z
  168 + init_values = 1
  169 +
  170 + if (xi > x):
  171 + xi = x
  172 + elif(xf < x):
  173 + xf = x
  174 +
  175 + if (yi > y):
  176 + yi = y
  177 + elif(yf < y):
  178 + yf = y
  179 +
  180 + if (zi > z):
  181 + zi = z
  182 + elif(zf < z):
  183 + zf = z
  184 +
  185 + clip = vtk.vtkImageClip()
  186 + clip.SetInput(imagedata)
  187 + clip.SetOutputWholeExtent(xi, xf, yi, yf, zi, zf)
  188 + clip.Update()
  189 +
160 190 gauss = vtk.vtkImageGaussianSmooth()
161   - gauss.SetInput(imagedata)
  191 + gauss.SetInput(clip.GetOutput())
162 192 gauss.SetRadiusFactor(0.6)
163 193 gauss.Update()
164 194  
165   - return gauss.GetOutput()
166   - #return imagedata
  195 + app = vtk.vtkImageAppend()
  196 + app.PreserveExtentsOn()
  197 + app.SetAppendAxis(2)
  198 + app.SetInput(0, imagedata)
  199 + app.SetInput(1, gauss.GetOutput())
  200 + app.Update()
  201 +
  202 + return app.GetOutput()
167 203  
168 204  
169 205 def Export(imagedata, filename, bin=False):
... ...