[Insight-users] itk::DiscreteGaussianImageFilter

Corinne Mattmann mattmaco at ee.ethz.ch
Mon, 26 Jan 2004 10:46:09 -0700


Hi,

I would like to create an image containing a sphere. To achieve this I'm
using itkEllipseSpatialObject, itkSpatialObjectToImageFilter and
itkDiscreteGaussianImageFilter (see attached code at the bottom). But it
seems that I get an image just consisiting of zeros.
That's why I took the example file ModelToImageRegistration1.cxx and
inputed the attached code at line 641 (just after
gaussianFilter->Update();) but with the same result: an empty image.

What am I doing wrong? Or is there might something wrong with the
itkDiscreteGaussianImageFilter?

Thanks,
Corinne


The code inputed at line 641:

    ImageType::IndexType index;
    index[0] = 0;
    index[1] = 0;
    int i=0;
    while((int)gaussianFilter->GetOutput()->GetPixel(index)==0){
      i++;
      index[0] = i%size[0];
      index[1] = floor((double)i/size[0]);
      if (i>=size[0]*size[1]){
        cout << "Image consists just of zeros!" << endl;
        break;
      }
    }
    for (int j=i; j<i+100; j++){
      if (j<size[0]*size[1]){
        index[0] = j%size[0];
        index[1] = ((int)floor((double)j/size[0])) % size[0];
        index[2] = floor((double)j/(size[0]*size[1]));
        cout << "Pixel sphere1 at " << index << ": "
          << (int)gaussianFilter->GetOutput()->GetPixel(index) << endl;
      }
      else
        break;
    }



My approach to get a sphere:

    ImageType::SizeType size;
      size[0] = 50;
      size[1] = 50;
      size[2] = 50;
//    ImageType::SpacingType spacing;
    double spacing[3];
      spacing[0] = 1;
      spacing[1] = 1;
      spacing[2] = 1;

  typedef itk::EllipseSpatialObject<Dimension> EllipseType;
    EllipseType::Pointer sphere1_spatialObject = EllipseType::New();
    sphere1_spatialObject->SetRadius(10);
    sphere1_spatialObject->SetSpacing(spacing);
  typedef itk::SpatialObjectToImageFilter<EllipseType, ImageType>
SpatialObjectToImageFilterType;
    SpatialObjectToImageFilterType::Pointer sphere1_filter =
SpatialObjectToImageFilterType::New();
    sphere1_filter->SetInput(sphere1_spatialObject);
    sphere1_filter->SetSize(size);
    sphere1_filter->SetInsideValue(127);
    sphere1_filter->SetOutsideValue(0);
    sphere1_filter->Update();
  typedef itk::DiscreteGaussianImageFilter<ImageType, ImageType>
GaussianFilterType;
    GaussianFilterType::Pointer sphere1_GaussianFilter =
GaussianFilterType::New();
    sphere1_GaussianFilter->SetInput(sphere1_filter->GetOutput());
    const double variance = 1;
    sphere1_GaussianFilter->SetVariance(variance);
    sphere1_GaussianFilter->Update();