[Insight-users] itk::Image to itk::OrientedImage

Luis Ibanez luis.ibanez at kitware.com
Fri Mar 16 10:59:57 EST 2007


Hi Sophie,


I see...


Then, here is the piece of code that you can use for creating
the OrientedImage from scratch, and copy the data from the
itk::Image that your read:



   typedef itk::Image< PixelType, Dimension > ImageType;

   typedef itk::OrientedImage< PixelType, Dimension > OrientedImageType;

   ImageType::ConstPointer itkImage = GetOutputFromYourReader();

   OrientedImage::Pointer orientedImage = OrientedImageType::New();

   orientedImage->CopyInformation( itkImage );
   orientedImage->SetRegions( itkImage->GetBufferedRegion() );
   orientedImage->Allocate();

   typedef itk::ImageRegionConstIterator< ImageType >
                                            ImageConstIteratorType;

   typedef itk::ImageRegionIterator< OrientedImageType >
                                            ImageIteratorType;

   ImageConstIteratorType src( itkImage, region );
   ImageIteratorType      dst( orientedImage, region );

   src.GoToBegin();
   dst.GoToBegin();

   while( !src.IsAtEnd() )
     {
     dst.Set( src.Get() );
     ++src;
     ++dst;
     }




  Regards,



      Luis



----------------------------
sblestel at irisa.fr wrote:
> Hi,
> 
> I can't do that because I don't use itkImageFileReader to read my image. I
> use a specific reader (because the format of the image is very specific).
> I can only obtain an itk::Image (3D) and I need to modify it to obtain an
> itk::OrientedImage (and I know the orientation of the image)
> 
> Thanks,
> 
>            Sophie
> 
> 
> 
>>HI Sophie,
>>
>>You can simply instantiate the itk::ImageFileReader
>>using an itk::OrientedImage as template argument.
>>
>>
>>The code will look like:
>>
>>
>>#include "itkOrientedImage.h"
>>#include "itkImageFileReader.h"
>>
>>typedef  signed short   PixelType;
>>const unsigned int Dimension = 3;
>>
>>typedef itk::OrientedImage< PixelType, Dimension > ImageType;
>>typedef itk::ImageFileReader< ImageType >  ReaderType;
>>
>>ReaderType::Pointer reader = ReaderType::New();
>>
>>reader->SetFileName( "myimage.hdr" );
>>reader->Update();
>>
>>ImageType::ConstPointer  image = reader->GetOutput();
>>
>>Note however, that, if you are trying to use IGSTK,
>>there are already specific reader developed in
>>IGSTK that encapsulate the ITK readers inside safe
>>state machine classes.
>>
>>
>>
>>
>>    Regards,
>>
>>
>>
>>         Luis
>>
>>
>>=====================================
>>On 3/15/07, sblestel at irisa.fr <sblestel at irisa.fr> wrote:
>>
>>>Hello,
>>>
>>>I use a specific image reader that only returns an itk::image, and I
>>>need
>>>an itk::OrientedImage to display my image (with igstk).
>>>Has a mapper already been done ?
>>>
>>>Thanks,
>>>
>>>Sophie
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>_______________________________________________
>>>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
> 


More information about the Insight-users mailing list