[Insight-developers] Bug in GPUDiscreteGaussianImageFilter?

Paul Yushkevich pauly2 at grasp.upenn.edu
Wed Sep 19 16:38:08 EDT 2012


Hi ITK developers,

I've encounted an issue with the GPUDiscreteGaussianImageFilter in ITK 4.2,
when used with a requested region that is not the same as the buffered
region of the output image.

Here is the code, meant to smooth a region of the input image:

#include <itkImageFileWriter.h>
#include <itkGPUImage.h>
#include <itkGPUDiscreteGaussianImageFilter.h>
#include <itkDiscreteGaussianImageFilter.h>
#include <itkRegionOfInterestImageFilter.h>

int main(int argc, char *argv[])
{
  itk::ObjectFactoryBase::RegisterFactory(itk::GPUImageFactory::New());

  typedef itk::GPUImage<float, 3> ImageType;
  typedef itk::ImageFileReader<ImageType> ReaderType;

  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName(argv[1]);
  reader->Update();

  typedef itk::GPUDiscreteGaussianImageFilter<ImageType, ImageType>
FilterType;
  FilterType::Pointer filter = FilterType::New();
  filter->SetInput(reader->GetOutput());
  filter->SetVariance(9.0);

  itk::ImageRegion<3> rr = reader->GetOutput()->GetBufferedRegion();
  rr.SetIndex(1, 64);
  rr.SetSize(1, 11);

  typedef itk::RegionOfInterestImageFilter<ImageType, ImageType> ROIType;
  ROIType::Pointer roif = ROIType::New();
  roif->SetInput(filter->GetOutput());
  roif->SetRegionOfInterest(rr);

  typedef itk::ImageFileWriter<ImageType> WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetInput(roif->GetOutput());
  writer->SetFileName(argv[2]);
  writer->Update();
}

When I execute the code above on a 3D image volume, I get garbled output
(as if when copied from one buffer to another, the wrong stride was
used). When I change "GPUDiscreteGaussianImageFilter" to
"DiscreteGaussianImageFilter",
I get the correctly smoothed output. All runs great when I don't use the
ROI filter (perform processing on the whole volume).

The same problem happens if I use the GPUMeanImageFilter, so I suspect the
problem is in the GPU neighborhood operator image filter.

Thanks!

-- 
Paul A. Yushkevich, Ph.D.
Assistant Professor
Penn Image Computing and Science Laboratory
Department of Radiology
University of Pennsylvania
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20120919/fb8e3534/attachment.htm>


More information about the Insight-developers mailing list