[Insight-users] Re: Deformation Field Iterator Type
Luis Ibanez
luis.ibanez at kitware.com
Thu Sep 14 09:55:54 EDT 2006
Hi Kevin,
Please read the ITK Software Guide
http://www.itk.org/ItkSoftwareGuide.pdf
In particular, Chapter 11, "Iterators" in pdf-pages 733-776.
Iterators will give you their current position in the
image grid when you call the "GetIndex()" method.
Then you can pass this Index() to the image in order to
compute the position of the iterator in physical space.
This can be done with code such as:
itk::Point<float,3> it2point;
vectorImage3D1->TransfromIndexToPhysicalPoint(
it2.GetIndex(), it2point );
---------
BTW: Your lines:
> vector3D1 = it2.Get();
> vector3D2[0] = vector3D1[0];
> vector3D2[1] = vector3D1[1];
> vector3D2[2] = vector3D1[2];
> it3.Set( vector3D2 );
can be reduced to
it3.Set( it2.Get() );
ITK Vectors and points provide an assignment operator,
so you don't need to copy the components one by one.
Regards,
Luis
--------------------
Kevin Ming wrote:
> Hi Luis,
>
> I've extended the Level Set deformable registration algorithm from 2D to
> the 3D case, including the deformation field generation. How would I go
> about accessing each of the voxels in the image, then accessing each of
> the 3 vector components within each voxel? I know it has something to
> do with the iterator, as coded below:
>
> typedef itk::ImageRegionConstIterator< VectorImage3D1Type > Iterator3D1Type;
>
> typedef itk::ImageRegionIterator< VectorImage3D2Type > Iterator3D2Type;
>
> Iterator3D1Type it2( vectorImage3D1, region3D1 );
> Iterator3D2Type it3( vectorImage3D2, region3D2 );
>
> it2.GoToBegin();
> it3.GoToBegin();
>
> Vector3D1Type vector3D1;
> Vector3D2Type vector3D2;
>
> while( !it2.IsAtEnd() )
> {
> vector3D1 = it2.Get();
> vector3D2[0] = vector3D1[0];
> vector3D2[1] = vector3D1[1];
> vector3D2[2] = vector3D1[2];
> it3.Set( vector3D2 );
> ++it2;
> ++it3;
> }
>
> But how do I know which voxel the iterator is on (ie. where it is in the
> image, in x,y,z components), especially when it's in 3D?
>
>
> Thank you,
> Kevin
More information about the Insight-users
mailing list