[Insight-developers] Re: Updates .. VectorImage

Karthik Krishnan Karthik.Krishnan at kitware.com
Fri Sep 16 12:32:53 EDT 2005


Gordon and Others:


A bunch of updates:

1. There is a Multi-variate Vector class : itkVariableLengthVector

Simply put, (as they say in the game Jeopardy:      FixedArray::Vector = 
Array::VariableLengthVector )

It doesn't derive from Array, primarily cause I did not want to derive 
from vnl_vector and have the explicit instantiations and other pains 
that it might bring with it. It does pretty much everything that Array 
can and provides a bunch of mathematical operators.

There are traits for this: NumericTraitsVariableLengthVector.

(There are still some minor issues with traits, to be resolved, for 
instance the Zero and One take in a reference to a pixel as input)

2. The VectorImage class uses this class instead of Array,

The motive for doing this was that we couldn't have linear filtering 
operations on Image< Array< .. > >. Now we can.

For instance below is a minimal code that does Gaussian smoothing on 
VectorImage. Note, as in the example below, that the VectorLength has to 
be manually passed through the pipeline.

As in

  filterX->GetOutput()->SetVectorLength( 
filterX->GetInput()->GetVectorLength() ); 

which is really not a big deal. Its just one more line for every filter 
you have. I could add this to ImageToImageFilter, so that VectorLength 
is also propagated along with Region information, but I would hate to 
have more puzzling typeid problems on SGI's as we just had before the 
release.... This is really not a big deal, Its just one additional line 
per filter, but if you think it is intrusive, I can just add this to 
ImageToImageFilter.

-----------------------------------------------------------------------------------------------------
#include "itkVectorImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRecursiveGaussianImageFilter.h"

int main( int argc, char * argv[] )
{
  if( argc < 4 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << "  inputImageFile  outputImageFile  sigma " 
<< std::endl;
    return EXIT_FAILURE;
    }
 
  typedef    unsigned char PixelType;
  const unsigned int Dimension = 3;
  typedef itk::VectorImage< PixelType, Dimension > ImageType;
  typedef itk::RecursiveGaussianImageFilter< ImageType, ImageType >  
FilterType;

  typedef itk::ImageFileReader< ImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( argv[1] );
  reader->Update();

  FilterType::Pointer filterX = FilterType::New();
  FilterType::Pointer filterY = FilterType::New();
  filterX->SetDirection( 0 );   // 0 --> X direction
  filterY->SetDirection( 1 );   // 1 --> Y direction
  filterX->SetOrder( FilterType::ZeroOrder );
  filterY->SetOrder( FilterType::ZeroOrder );
  filterX->SetNormalizeAcrossScale( false );
  filterY->SetNormalizeAcrossScale( false );
  filterX->SetInput( reader->GetOutput() );
  filterX->GetOutput()->SetVectorLength( 
filterX->GetInput()->GetVectorLength() );  //NOTE
  filterY->SetInput( filterX->GetOutput() );
  filterY->GetOutput()->SetVectorLength( 
filterY->GetInput()->GetVectorLength() );  //NOTE
  const double sigma = atof( argv[3] );
  filterX->SetSigma( sigma );
  filterY->SetSigma( sigma );
 
  typedef  unsigned char  WritePixelType;
  typedef itk::VectorImage< PixelType, Dimension >    WriteImageType;
  typedef itk::ImageFileWriter< WriteImageType >  WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName( argv[2] );
  writer->SetInput( filterY->GetOutput() );
  writer->Update();

  return EXIT_SUCCESS;
}
-----------------------------------------


Thanks
Regards
Karthik






Gordon Kindlmann wrote:

> hello,
>
>>>  One could further
>>> imagine doing vector-valued non-linear filtering (such as anisotropic
>>> diffusion), which requires some notion of a gradient.
>>
>>
>> I can certainly see operators for linear filters.. How do you define
>> non-linear operators on the pixel type ?
>>
>> What is exp( Array< float > ) ?
>
>
> I'm sorry, I was being too clever when I said this.  My only point  
> was that you want to be able to measure some kind of a gradient, in  
> order to implement non-linear filtering.  I wasn't referring to non- 
> linear operations (like exp()) on pixels themselves; and I can't  
> currently imagine a use for such an operation.
>
> Gordon
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>


More information about the Insight-developers mailing list