[Insight-users] QUestion on iterator need help please

marcellus walace marcelluswalace at hotmail . com
Mon, 18 Aug 2003 18:37:52 +0200


Ok thanks Luis,

I've got antoher problem...I'm using itk::ImageLinearIteratorWithIndex and 
itk::ImageLinearConstIteratorWithIndex to copy regions from an image to one 
another.
But I've a runtime error because of this instruction

outputIt.Set( inputIt.Get() );  at the end of my code I've joined down...

when I remove it all is going on...but when I add it...it the crash...Can 
you help me please...
I've copy it from the user guide....ImageType has been defined as  
itk::image<float, 3>.

  typedef itk::ImageLinearIteratorWithIndex<ImageType> IteratorType;
  typedef itk::ImageLinearConstIteratorWithIndex<ImageType> 
ConstIteratorType;
  typedef itk::ImageFileReader< ImageType > ReaderType;

  //num=1;
  //sprintf(currentName, "%s%d", pref,num);

  std::cout << "Loading File: " << pref << std::endl;

  ReaderType::Pointer unreader= ReaderType::New();
  unreader->SetFileName(pref);

  ImageType::Pointer inputImage;

  try
    {
    unreader->Update();
    }
  catch( itk::ExceptionObject & exception )
    {
    std::cout << "Problems reading file format" << std::endl;
    std::cout << exception << std::endl;
    }
  std::cout << "...Done Loading File" << std::endl;

  inputImage = unreader->GetOutput();


  ImageType::Pointer outputImage = ImageType::New();
  outputImage->SetRegions( inputImage->GetRequestedRegion() );
  outputImage->CopyInformation( inputImage );
  outputImage->Allocate();



  ConstIteratorType inputIt( inputImage, inputImage->GetRequestedRegion() );
  IteratorType outputIt( outputImage, outputImage->GetRequestedRegion() );

  inputIt.SetDirection(0);
  outputIt.SetDirection(0);


  for (inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd(); 
outputIt.NextLine(),inputIt.NextLine()){

   inputIt.GoToBeginOfLine();
   outputIt.GoToBeginOfLine();
   --outputIt;

   while( !inputIt.IsAtEndOfLine() ){

	//   outputIt.Set( inputIt.Get() );
	   ++inputIt;
	   --outputIt;

   }//end of while loop

  }// end for loop


}

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
http://join . msn . com/?page=features/virus