[Insight-users] How to get one 4d image from 3d volume data?

Miller, James V (Research) millerjv at crd . ge . com
Mon, 8 Dec 2003 08:57:02 -0500


Hideaki, 

You can use the CastImageFilter to create a 4D image from a 3D image.
You'll need to instantiate a CastImageFilter that takes a 3D image as 
input and a 4D image as output. The output will be a 4D image with the
final dimension being 1.  

If you have a 4D image of the appropriate size, you can paste the contents
of a 3D image into the 4D image by casting the 3D image into a 4D image 
as above and then pasting the result into a 4D image.  You can use the 
PasteImageFilter for that.

To do the whole job, you'll probably end up using the CastImageFilter, 
PasteImageFilter, ExtractImageFilter and ConstantPadImageFilter.

Jim




-----Original Message-----
From: Luis Ibanez [mailto:luis . ibanez at kitware . com]
Sent: Sunday, December 07, 2003 11:31 AM
To: hhiraki at lab . nig . ac . jp
Cc: insight-users at itk . org
Subject: Re: [Insight-users] How to get one 4d image from 3d volume
data?



Hi Hideaki,


1) If you want to apply 3D processing to pieces of
    4D data, what you need is a filter that will
    extract 3D volumes from the 4D data.

    For that purpose you can use the ExtractImageFilter.
    It can get an N-D input and produce a (N-M)-D output.


2) If what you want is to collect the 3D pieces resulting
    from the VTK processing, and put them back into a 4D image,
    then I'm affraid we don't have an easy filter for doing
    that.

    you can however do it with the following 20 lines of code,
    where we assume that you have an array of smart pointers
    to your 3D images, and also assume that your 4D image
    extent is equal to the union off all the 3D image extents:



    typedef itk::Image< PixelType, 3 >  Image3DType;
    typedef itk::Image< PixelType, 4 >  Image4DType;

    std::vector< Image3DType::Pointer > images =
                                           GetImagesSomewho();

    typedef itk::ImageRegionConstIterator< Image3DType >  Iterator3D;
    typedef itk::ImageRegionConstIterator< Image4DType >  Iterator4D;

    Iterator4D it4( image4D, image4D->GetBufferedRegion() );
    it4.GoToBegin();

    for(unsigned int i=0; i<NumberOf3DImages; i++)
      {
      Image3DType::RegionType region = images[i]->GetBufferedRegion();
      Iterator3D it3( images[i], region );
      it3.GoToBegin();
      while( !it3.IsAtEnd() )
        {
        it4.Set( it3.Get() );
        ++it3;
        ++it4;
        }
      }




Please let us know if you have further questions,


Thanks


   Luis



---------------------------------
hhiraki at lab . nig . ac . jp wrote:
> I'd like to try 3D image processing on (parts of) 4D data, 
> for example, using a vtk filter. 
> Does your answer suggest there is no filter for now that 
> outputs (N+1)-D image from N-D image and the workaround 
> is writing N-D data files and reading them as a (N+1)-D 
> data?
> Thanks
> 
> Luis Ibanez wrote:
> 
>>Hi Hideaki,
>>
>>Do you have your 4D data as a series of 3D datasets files ?
>>
>>If this is the case you could simply use the ImageSeriesReader
>>http://www . itk . org/Insight/Doxygen/html/classitk_1_1ImageSeriesReader . html
>>
>>Instantiate it in 4D and provide a set 3D volumes as input.
>>
>>Please let us know if you have further questions,
>>
>>
>>Thanks
>>
>>
>>   Luis
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
> 



_______________________________________________
Insight-users mailing list
Insight-users at itk . org
http://www . itk . org/mailman/listinfo/insight-users