[Insight-users] output of filter, image filled with zeros

Ghassan Hamarneh ghamarneh@yahoo.com
Fri, 29 Nov 2002 12:06:47 -0500 (EST)


Hello,

I am trying to read a 3d image, perform simple filtering, and write the output
to file. I able to read the image (mhd+raw) and write it directly to a new file
without problems (writer->SetInput(reader->GetOutput()); //bypass filter).
However, if I include the filter "itkGradientMagnitudeImageFilter" into the
pipeline the saved image of the correct size and type but is all zeros . Can
you spot the problem in my code? My appologies if this turns out to be very
trivial, I am an ITK beginner.

/Thank you.
Ghassan

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkGradientMagnitudeImageFilter.h"
#include "itkRawImageWriter.h"

int main( int argc, char **argv){
  typedef itk::Image <unsigned short, 3> ImageType;
  typedef itk::ImageFileReader<ImageType> ReaderType;
  typedef itk::RawImageWriter<ImageType> WriterType;
  typedef itk::GradientMagnitudeImageFilter<ImageType,ImageType> FilterType; 
  
  ReaderType::Pointer reader = ReaderType::New();
  FilterType::Pointer filter = FilterType::New();
  WriterType::Pointer writer = WriterType::New();

  reader->SetFileName(argv[1]);

  filter->SetInput(reader->GetOutput());
  filter->Update();
  writer->SetInput(filter->GetOutput());

  //writer->SetInput(reader->GetOutput()); //bypass filter

  writer->SetFileName(argv[2]);
  writer->SetFileTypeToBinary();
  writer->Write();
  return 0;
}





______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca