[Insight-users] About NthElementImageAdaptor usage

Matt McCormick matt at mmmccormick.com
Thu Jun 10 10:53:33 EDT 2010


Sergio Vera <sergio.vera at ...> writes:

> 
> Hello allIt seems to me that I can use NthElementImageAdaptor to redistribute 
the components of a vector image into different "layers" and then use normal 
scalar filters to process the data. However I don't know if to apply say a 
Gaussian to all the "layers" can be done with a single call to Update or I have 
to select each layer individually and then call Update once for each layerAny 
examples of usage?Regards-- Sergio Vera Alma IT Systems C/ Vilana, 4B, 4º 1ª 
08022 Barcelona T. (+34) 932 380 592www.alma3d.com

Hi Sergio,

You must call Update for each element, e.g.,

  typedef itk::NthElementImageAdaptor< TensorImageType, PixelType > AdaptorType; 
  AdaptorType::Pointer adaptor = AdaptorType::New();

...

  filter->Update();
  adaptor->SetImage( filter->GetOutput() );

  std::ostringstream ostr;
  try
    {
    tensorWriter->Update();
    for( unsigned int i = 0; i < 6; ++i )
      {
      ostr.str( "" );
      ostr << argv[2] << "Component" << i << ".mha";
      adaptor->SelectNthElement( i );
      adaptor->Update();
      itk::ImageRegionConstIterator< AdaptorType > adaptorIt( adaptor,
        adaptor->GetBufferedRegion() );
      itk::ImageRegionIterator< ComponentImageType > outputIt( outImage,
        outImage->GetLargestPossibleRegion() );
      for( adaptorIt.GoToBegin(), outputIt.GoToBegin();
        !adaptorIt.IsAtEnd();
        ++adaptorIt, ++outputIt )
        {
        outputIt.Set( adaptorIt.Get() );
        }
      tensorComponentWriter->SetFileName( ostr.str() );
      tensorComponentWriter->Update();
      }

If you want to do it in one Update(), try this filter:

http://gitorious.org/itk-repos/itk-tensor-components







More information about the Insight-users mailing list