[Insight-users] Copy filter output

Luis Ibanez luis.ibanez at kitware.com
Wed, 14 Jan 2004 10:54:06 -0500


Hi Silvano,

Welcome to ITK !

 From your message it looks like you are trying to
create one RecursiveGaussianImageFilter and
reuse it in order to compute multiple second
derivatives.

Reusing filters is a bad practice in a data
pipepline system as ITK or VTK.

Don't be affraid to be generous in creating ITK
filters (unless your images are really large).



I assume that you are trying to compute the full
set of second derivatives in a 3D image, which
is equivalent to compute the Hessian Matrix for
every pixel


            Ixx  Ixy  Ixz
            Iyx  Iyy  Iyz
            Izx  Izy  Izz


given that this is a symmetric matrix, you only
need to compute the 6 images:

    {  Ixx   Iyy  Izz   Ixy  Ixz  Iyz  }


Let's take Izz first


You need 3 RecursiveGaussianImageFilters in order
to compute the Izz image.

FilterType::Pointer ga = FilterType::New();
FilterType::Pointer gb = FilterType::New();
FilterType::Pointer gc = FilterType::New();

ga->SetDirection( 0 );
gb->SetDirection( 1 );
gc->SetDirection( 2 );

ga->SetZeroOrder();
gb->SetZeroOrder();
gc->SetSecondOrder();

ga->SetInput( inputImage );
gb->SetInput( ga->GetOutput() );
gc->SetInput( gb->GetOutput() );

gc->Update();

At this point you have Izz as the output of the
filter "gc".

You can copy this output out of the pipeline
by using the ImageDuplicator class
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageDuplicator.html

DuplicatorType::Pointer duplicator = DuplicatorType::New();

duplicator->SetInput(  gc->GetOutput() );
duplicator->Update();

SecondDerivativeImageType::Pointer Izz = duplicator->GetOutput();


Note the "duplicator" is NOT an ITK filter.
It doesn't to make part of the pipeline,
despite the fact that its API look like
a filter.




Now, you can readjust the pipeline in order
to compute Iyy, just do

gc->SetDirection( 1 );  // gc now works along Y
gb->SetDirection( 2 );  // gb now works along Z

gc->Update();
duplicator->Update();

SecondDerivativeImageType::Pointer Iyy = duplicator->GetOutput();




In order to get Ixx you do

gc->SetDirection( 0 );  // gc now works along X
ga->SetDirection( 1 );  // ga now works along Y

gc->Update();
duplicator->Update();

SecondDerivativeImageType::Pointer Ixx = duplicator->GetOutput();






For the cross derivatives you do

ga->SetDirection( 0 );
gb->SetDirection( 1 );
gc->SetDirection( 2 );

ga->SetZeroOrder();
gb->SetSecondOrder();
gc->SetSecondOrder();

gc->Update();
duplicator->Update();

SecondDerivativeImageType::Pointer Iyz = duplicator->GetOutput();


ga->SetDirection( 1 );
gb->SetDirection( 0 );
gc->SetDirection( 2 );

ga->SetZeroOrder();
gb->SetSecondOrder();
gc->SetSecondOrder();

gc->Update();
duplicator->Update();

SecondDerivativeImageType::Pointer Ixz = duplicator->GetOutput();


ga->SetDirection( 2 );
gb->SetDirection( 0 );
gc->SetDirection( 1 );

ga->SetZeroOrder();
gb->SetSecondOrder();
gc->SetSecondOrder();

gc->Update();
duplicator->Update();

SecondDerivativeImageType::Pointer Ixy = duplicator->GetOutput();





Regards,


    Luis


------------------------
Silvano Agliozzo wrote:

> Dear all,
> 
> I'am a newcomer to the Itk libraries, so I could ask a trivial and I 
> apologize in advance.
> 
> I need to use the RecursiveGuassianImageFilter in a 3D image in order to 
> obtain second order derivatives, but I need to store the output of the filter 
> to different 3D images. I do not want to get the pointer of the filter 
> output since each time the pipeline of the filter is updated, the voxel 
> values of all the images previously calculated, are updated too. 
> 
> I would like to know how  can I perform this task ? 
> 
> thank you very much,
> 
> Silvano  
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>