[Insight-users] Iterators ??

Lagaffe lagaffe74130 at yahoo.fr
Sun Feb 5 05:02:41 EST 2006


Hi all,

Just because I am curious ;-), I would like to
understand why the method2 below doesn't works ??

I Have a vectorial Image, and I would like to
"extract" an image from this vectorial image (the
simple code below is simple to understand ;-)...

OutputImageType  aPixelType
ImageType  a vectorial image (vector< aPixelType,3>
for example)


// METHOD 1 => OK
typedef typename
itk::ImageLinearConstIteratorWithIndex< ImageType > 
ConstIteratorType;
  
for (inputIt.GoToBegin (); !inputIt.IsAtEnd ();
inputIt.NextLine ())
		{
			inputIt.GoToBeginOfLine ();
			while (!inputIt.IsAtEndOfLine ())
			{
				index=inputIt.GetIndex ();
				vectorPixel=outputImage->GetPixel(index);
				vectorPixel[i]=inputIt.Get();  // i, the slice I
want to extract from my vectorial image  
				outputImage->SetPixel(index,vectorPixel);
				++inputIt;
			}
		}
		

// METHOD 2 => Failed, the for loop goes far from my
image length ??, I added a simple cpt inside the loop
and find values of cpt > of sizeX*sizeY

    typedef typename
itk::ImageLinearIteratorWithIndex< OutputImageType >  
    IteratorType;
    typedef typename
itk::ImageLinearConstIteratorWithIndex< ImageType > 
ConstIteratorType;
  
	
		 ConstIteratorType in( temp,
temp->GetRequestedRegion() ); 
		 IteratorType out( outputImage,
inputImage->GetRequestedRegion() ); 
		 for ( in.GoToBegin(), out.GoToBegin();
!in.IsAtEnd(); ++in, ++out ) 
		 { 
			 vectorPixel=out.Get(); 		
			 vectorPixel[i]=in.Get();  
			 out.Set( vectorPixel); 
		 } 


thanks

Arnaud


	

	
		
___________________________________________________________________________ 
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


More information about the Insight-users mailing list