[ITK] Using spatialObjects as filters

Leslie Solorzano lesolorzanov at gmail.com
Thu Apr 9 09:17:59 EDT 2015


Hello world.

I want to use a gaussianSpatialObject and
a SpatialObjectToImageStatisticsCalculator to filter an image and make a
gaussian convolution. Why not using a DiscreteGaussianImageFilter? easy, I
need a gaussian with different radii in each dimension and I need to be
able to set the size, the maximum value and the sigma, which only a
gaussianSpatialObject can offer me.

I managed to make a sort of filter ussing the SpatialObject offset, the
problem is I have to instantiate the SpatialObject for each voxel, or else
it will not update the StatisticsCalculator.

For instance a loop through the image looks like this.

for(int i=0;i<50;i++){
    for(int j=0;j<50;j++){
      GaussianType::Pointer gaussian = GaussianType::New();
      gaussian->SetRadius(5); //I can set radius for each dimension
      gaussian->SetMaximum(1);
      gaussian->SetSigma(2);
      offset[0]=i;
      offset[1]=j;
      gaussian->GetIndexToObjectTransform()->SetOffset(offset);
      gaussian->ComputeObjectToParentTransform();

      calculator->SetImage(image);
      calculator->SetSpatialObject(gaussian);
      calculator->Update();

      //save this to new image or just cout it
      std::cout<<calculator->GetMean()<<" ";
    }
  }

but I wish I could just update the offset. I am using ITK 4.7 and I just
found that Some spatial functions exist in 4.8 but there are no examples on
how to use them anyway.

update: I found out I just needed to update the gaussian object as well

is there anyway I can use DiscreteGaussianImageFilter with different radii?
can I set the maximum value?

Thankyou for your attention
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150409/0115b482/attachment.html>


More information about the Community mailing list