[vtkusers] using vtkGaussianSplatter to splat single voxels only

Dr. Roman Grothausmann grothausmann.roman at mh-hannover.de
Tue Jan 6 03:09:17 EST 2015


Dear mailing list members,


For a contribution to the Midas Journal I need a filter that splats single 
voxels at specific point positions. Basically, vtkGaussianSplatter with a Radius 
of 0. However, the output of vtkGaussianSplatter when setting the radius to 0 is 
always an empty image. Looking at the relevant code in vtkGaussianSplatter.cxx 
(ll230), I can't see a way to make SetScalar put a voxel in this case without 
any modifications to the code. Formerly I had applied a patch (see below) that 
handles the case of Radius == 0 specially. However, for the publication I'd like 
to avoid patching VTK, for simplicity and to make use of the automatic testing 
environment. So I tried a Radius that corresponds to 1 voxel, i.e. 
SetRadius(1.0/(SampleDimension+1)), but due to the use of floor and ceil for min 
and max of the footprint there are cases in which this yields more than one 
splat voxel for a given input point.
What would be the best way to achieve single voxel splats without patching 
vtkGaussianSplatter?
Or should I use another filter or include my modified vtkGaussianSplatter into 
the code of the publication?

Any help or hints are very much appreciated
Roman

_____________________________

diff -aur VTK-6.1.0_orig/Imaging/Hybrid/vtkGaussianSplatter.cxx 
VTK-6.1.0/Imaging/Hybrid/vtkGaussianSplatter.cxx
--- VTK-6.1.0_orig/Imaging/Hybrid/vtkGaussianSplatter.cxx	2014-01-22 
16:55:41.000000000 +0100
+++ VTK-6.1.0/Imaging/Hybrid/vtkGaussianSplatter.cxx	2014-10-21 
16:21:41.848542330 +0200
@@ -226,11 +226,29 @@
        loc[i] = (this->P[i] - this->Origin[i]) / this->Spacing[i];
        }

+    if (this->Radius == 0){
+        char splatit= 1;
      // Determine splat footprint
      for (i=0; i<3; i++)
        {
-      min[i] = 
static_cast<int>(floor(static_cast<double>(loc[i])-this->SplatDistance[i]));
-      max[i] = 
static_cast<int>(ceil(static_cast<double>(loc[i])+this->SplatDistance[i]));
+            min[i] = static_cast<int>(round(loc[i]));
+            if ( min[i] < 0 || min[i] >= this->SampleDimensions[i] )
+                {
+                splatit= 0;
+                }
+            }
+        if (splatit){
+            idx = min[0] + min[1]*this->SampleDimensions[0] + min[2]*sliceSize;
+            this->SetScalar(idx,0, newScalars);
+            }
+        }
+
+    else {
+        // Determine splat footprint
+        for (i=0; i<3; i++)
+            {
+            min[i] = static_cast<int>(round(loc[i] - this->SplatDistance[i]));
+            max[i] = static_cast<int>(round(loc[i] + this->SplatDistance[i]));
        if ( min[i] < 0 )
          {
          min[i] = 0;
@@ -260,6 +278,7 @@
            }
          }
        }//within splat footprint
+        }
      }//for all input points

    // If capping is turned on, set the distances of the outside of the volume
@@ -513,7 +532,11 @@
  void vtkGaussianSplatter::SetScalar(int idx, double dist2,
                                      vtkDoubleArray *newScalars)
  {
-  double v = (this->*SampleFactor)(this->S) * exp(
+  double v;
+  if (this->Radius2 == 0)
+      v = (this->*SampleFactor)(this->S);
+  else
+      v = (this->*SampleFactor)(this->S) * exp(
      static_cast<double>
      (this->ExponentFactor*(dist2)/(this->Radius2)));



-- 
Dr. Roman Grothausmann

Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis

Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover

Tel. +49 511 532-9574


More information about the vtkusers mailing list