[Insight-users] copy slice into volume
Luis Ibanez
luis . ibanez at kitware . com
Tue, 03 Sep 2002 16:02:11 -0400
Hi Mark,
ImageIterators are probably the best choice for
inserting a 3D image as a slice of a 4D image.
(or a 2D image as slice of a 3D image).
There is a filter for the reverse operation though:
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ExtractImageFilter.html#_details
It could extract a 3D image from a 4D, or a 2D
image from a 3D image.
You may use code similar to the following:
typedef itk::Image< chat, 3 > Image3DType;
typedef itk::Image< chat, 4 > Image4DType;
Image3DType::Pointer image3D = GetImage3DSomeHow();
Image3DType::Pointer image4D = GetImage4DSomeHow();
typedef itk::ImageRegionIterator<Image3DType> Iterator3D;
typedef itk::ImageRegionIterator<Image4DType> Iterator4D;
Image3DType::RegionType region3D;
region3D = image3D->GetBufferedRegion()
Iterator3D it3( image3D, region3D );
Image4DType::RegionType region4D;
// ... figure out how the region of the 3D image
// should be placed in the corresponding region
// of the 4D image....
// Fill region4D with this information
Iterator3D it4( image4D, region4D );
it3D.GoToBegin();
it4D.GoToBegin();
while( !it3D.IsAtEnd() )
{
it4D.Set( it3D.Get() ); // copy a pixel
++it3D;
++it4D;
}
Please let us know if you find any problem with
these iterators.
Thanks,
Luis
=======================================
Mark Hastenteufel wrote:
> Hello!
>
> My problem is the following:
>
> I want to copy a 2D (3D) Image into a slice of a 3D (4D) image.
>
> What is the best way to do this? Should I use ImageIterators or is there
> something else.
>
> Many Thanks,
>
> Mark
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>
>