[Insight-users] QUestion on iterator need help please
Joshua Cates
cates at sci . utah . edu
Mon, 18 Aug 2003 10:42:17 -0600 (MDT)
Hi Marcellus,
Are you using an ITK release or the latest CVS? Previously there was an
inconsistency in some of the iterator classes regarding how "End" was
defined that will cause a possible crash in this code. Latest versions of
the iterators have corrected this.
Josh.
______________________________
Josh Cates
Scientific Computing and Imaging Institute
University of Utah
Email: cates at sci . utah . edu
Phone: (801) 587-7697
URL: http://www . sci . utah . edu/~cates
On Mon, 18 Aug 2003, marcellus walace wrote:
>
> 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
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>