[Insight-users] Why MultiResolutionPyramidImageFilter does not produce right image?

Fucang Jia jiafucang at hotmail . com
Wed, 19 Nov 2003 17:17:00 +0800


Hi, everyone,

I am using ITK 1.4 and want to do some experiments based on 
MultiResolutionPyramid. But the following program does not give correct 
images. It does produce 8 images, but the first level image is all zeros. So 
the error spreads to the next level images. Is there some error in this 
program?

Thanks a lot!

Fucang


=============================
int main(int argc, char *argv[] )
{


  if(argc<2)
  {
   std::cerr<<argv[0]<<" Input2DImage"<<std::endl;
   return -1;
  }

  typedef unsigned short PixelType;
  const unsigned short Dimension = 2;

  typedef itk::Image<PixelType,Dimension>       InputImageType;
  typedef itk::Image<PixelType,Dimension>       OutputImageType;
  typedef itk::ImageFileReader<InputImageType>  ReaderType;
  typedef itk::ImageFileWriter<OutputImageType> WriterType;
  typedef 
itk::MultiResolutionPyramidImageFilter<InputImageType,OutputImageType>
    PyramidType;
  ReaderType::Pointer  reader  = ReaderType::New();
  WriterType::Pointer  writer  = WriterType::New();
  PyramidType::Pointer pyramid = PyramidType::New();


  reader->SetFileName(argv[1]);
  reader->Update();

  pyramid->SetInput( reader->GetOutput() );

  unsigned int numLevels;
  itk::Vector<unsigned int,Dimension> factors;

  numLevels = 8;
  factors[0] = 256; factors[1] = 256;

  pyramid->SetNumberOfLevels( numLevels );
  pyramid->SetStartingShrinkFactors( 256 );
  pyramid->Print( std::cout );

  pyramid->Update();

  for (int i=0;i<numLevels;i++)
  {
   char str[4096];
   sprintf(str,"test_%d.png",i);
   writer->SetFileName(str);
   writer->SetInput(pyramid->GetOutput(i));
   writer->Update();
  }

  return 0;
}

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join . msn . com/?page=features/junkmail