Commit 53e99da85d4acc68b2ccd220356b9fe11eb91f0b

Authored by tfmoraes
1 parent bc5cd630

ENH: Applying the convolution filter when a new raycasting preset is setted

Showing 1 changed file with 18 additions and 10 deletions   Show diff stats
invesalius/data/volume.py
... ... @@ -129,6 +129,8 @@ class Volume():
129 129 else:
130 130 self.Create8bColorTable(self.scale)
131 131 self.Create8bOpacityTable(self.scale)
  132 + image = self.DoConvolutionFilters(self.imagedata.GetOutput())
  133 + self.volume_mapper.SetInput(image)
132 134  
133 135 def OnSetRelativeWindowLevel(self, pubsub_evt):
134 136 diff_ww, diff_wl = pubsub_evt.data
... ... @@ -327,6 +329,15 @@ class Volume():
327 329 self.volume_properties.SetSpecular(shading['specular'])
328 330 self.volume_properties.SetSpecularPower(shading['specularPower'])
329 331  
  332 + def DoConvolutionFilters(self, imagedata):
  333 + for filter in self.config['convolutionFilters']:
  334 + convolve = vtk.vtkImageConvolve()
  335 + convolve.SetInput(imagedata)
  336 + convolve.SetKernel5x5([i/60.0 for i in Kernels[filter]])
  337 + convolve.Update()
  338 + imagedata = convolve.GetOutput()
  339 + return imagedata
  340 +
330 341 def LoadVolume(self):
331 342 proj = Project()
332 343 image = proj.imagedata
... ... @@ -340,7 +351,6 @@ class Volume():
340 351  
341 352 image = flip.GetOutput()
342 353  
343   -
344 354 scale = image.GetScalarRange()
345 355 self.scale = scale
346 356  
... ... @@ -350,6 +360,7 @@ class Volume():
350 360 cast.SetOutputScalarTypeToUnsignedShort()
351 361 cast.Update()
352 362 image2 = cast
  363 + self.imagedata = image2
353 364 if self.config['advancedCLUT']:
354 365 self.Create16bColorTable(scale)
355 366 self.CreateOpacityTable(scale)
... ... @@ -357,12 +368,7 @@ class Volume():
357 368 self.Create8bColorTable(scale)
358 369 self.Create8bOpacityTable(scale)
359 370  
360   - convolve = vtk.vtkImageConvolve()
361   - convolve.SetInput(image2.GetOutput())
362   - convolve.SetKernel5x5([i/60.0 for i in Kernels[self.config['convolutionFilters'][0]]])
363   - convolve.Update()
364   -
365   - image2 = convolve
  371 + image2 = self.DoConvolutionFilters(image2.GetOutput())
366 372  
367 373 composite_function = vtk.vtkVolumeRayCastCompositeFunction()
368 374 composite_function.SetCompositeMethodToInterpolateFirst()
... ... @@ -376,22 +382,24 @@ class Volume():
376 382 if const.TYPE_RAYCASTING_MAPPER:
377 383 volume_mapper = vtk.vtkVolumeRayCastMapper()
378 384 #volume_mapper.AutoAdjustSampleDistancesOff()
379   - volume_mapper.SetInput(image2.GetOutput())
  385 + volume_mapper.SetInput(image2)
380 386 volume_mapper.SetVolumeRayCastFunction(composite_function)
381 387 #volume_mapper.SetGradientEstimator(gradientEstimator)
382 388 volume_mapper.IntermixIntersectingGeometryOn()
383 389 else:
384 390 volume_mapper = vtk.vtkFixedPointVolumeRayCastMapper()
385 391 #volume_mapper.AutoAdjustSampleDistancesOff()
386   - volume_mapper.SetInput(image2.GetOutput())
  392 + volume_mapper.SetInput(image2)
387 393 volume_mapper.IntermixIntersectingGeometryOn()
388 394  
  395 + self.volume_mapper = volume_mapper
  396 +
389 397 # TODO: Look to this
390 398 #volume_mapper = vtk.vtkVolumeTextureMapper2D()
391 399 #volume_mapper.SetInput(image2.GetOutput())
392 400  
393 401 #Cut Plane
394   - CutPlane(image2.GetOutput(), volume_mapper)
  402 + CutPlane(image2, volume_mapper)
395 403  
396 404 #self.color_transfer = color_transfer
397 405  
... ...