[Insight-users] rotating data with in a 3D array

Luis Ibanez luis.ibanez at kitware.com
Mon Sep 12 08:42:27 EDT 2005


Hi Rama,

In order to create an itk::Image from your C++ array, you can use
the ImportImageFilter, as described in the ITK Software Guide:

            http://www.itk.org/ItkSoftwareGuide.pdf

In particular in Section 4.1.7 "Importing Image Data from a Buffer",
in pdf-page 78.


Once you set up your importer filter, you can pass the output of the
importer to the resample image filter as:

            resampler->SetInput( importer->GetOutput() );

then run the filter

            resampler->Update();

then get the buffer back

    ImageType::PixelContainer  * container;
    container = filter->GetOutput()->GetPixelContainer();
    buffer = container->GetImportPointer();

and *VERY* important, mummifying the buffer so it doesn't get
destroyed when the resampler filter is destroyed.


    container->SetContainerManageMemory( false );


You will also find useful to read the Tutorials, in particular
the one describing Integration of ITK with your application.
That tutorial describes how to exchange data between ITK filters
and the typical C++ arrays used in applications.


    Regards,


       Luis


---------------
rama wrote:
> Hi Luis,
> 
> I have read the documentation that you have suggested and it has been 
> quite useful. But I want to clarify a small doubt before starting to 
> attempt it.
> 
> That is, how to give input data and how to collect output data.
> 
> The manual says input can be obtained from any filter and there are 
> functions like,
> filter->SetInput( reader->GetOutput() );
> writer->SetInput( filter->GetOutput() );
> writer->Update();   // to trigger the operation
> 
> But I have the data as a normal C++ array. I have the data as,
>    unsigned int *data[X*Y*Z].
> So the whole 3D data is packed as a single array.
> 
> Shall I just write
>    filter->SetInput(data);
> and
>    data=filter->GetOutput();
> 
> I am bit confused about how to give the input and how to collect the 
> output.
> 
> Can you please clarify this doubt to me.
> 
> thank you,
> Rama.
> 
> Luis Ibanez wrote:
> 
>>
>> Hi Rama,
>>
>> Please read the ITK Software Guide.
>>
>>    http://www.itk.org/ItkSoftwareGuide.pdf
>>
>> In particular, you should read Section 6.9,
>> "Geometric Transformations" in pdf-page 249.
>>
>>
>> This section describes in detail how to use the
>>
>>              itk::ResampleImageFilter<>
>>
>> in order to apply rotations and translation to images.
>>
>>
>> Note that for a rotation you probably want to use the
>> itk::VersorRigid3DTransform, as described in that section,
>> and you want to initilize the transform using the
>> itk::CenteredTransformInitializer.
>>
>>
>> Source code for these examples is available in
>>
>>
>>      Insight/Examples/Filtering/
>>            ResampleImageFilter.cxx
>>            ResampleImageFilter2.cxx
>>            ResampleImageFilter3.cxx
>>            ResampleImageFilter4.cxx
>>            ResampleImageFilter5.cxx
>>            ResampleImageFilter6.cxx
>>            ResampleImageFilter7.cxx
>>            ResampleImageFilter8.cxx
>>            ResampleImageFilter9.cxx
>>
>>
>>
>>   Regards,
>>
>>
>>      Luis
>>
>>
>>
>> --------------------
>> rama wrote:
>>
>>> Hi,
>>>
>>> I am looking for a way to rotate data within a 3D array. I have a 3D 
>>> array with dimensions X*Y*Z with each value being an integer in the 
>>> range 0-255 which actually represents a gray scale 3D image.
>>> Now I want to rotate the image in that array, by this I mean, I want 
>>> to rotate the data with in that 3D array and store the result in the 
>>> array of same dimensions.
>>>
>>> I have come accross the MultiResMIRegistration example in ITK 2.0.0 
>>> distribution. I have seen it rotating a 3D data set (array) to 
>>> register with another 3D data set. I have seen its code but there is 
>>> little help in it. I have also seen the Transform class in ITK. But 
>>> it doesn't give any information about how to trigger the 
>>> transformation and will it transform the whole 3D array in a single go.
>>>
>>> Can anyone give an idea of how to do rotations on data with in a 3D 
>>> array.
>>>
>>> thanks,
>>> Rama.
>>>
>>> _______________________________________________
>>> 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