[Insight-users] Image Adaptor Spacing Problem

Michael Hardisty m.hardisty at utoronto.ca
Mon Jan 30 16:41:53 EST 2006


Hello Insight Users,
    I am having trouble with the NthElementImageAdaptor.  The main 
trouble that I seem to be having is that the adaptor is not passing on 
the spacing or origin information that is contained in the input image.  
I am trying to extract a component of a vector that I have in an image 
of type itk::Image<itk::Vector< float, 3 >,3>.  What my code is 
currently doing is I pass the output of the NthElementImageAdaptor to a 
shiftscale image filter that I then use further in the program.  I have 
checked the output of the shiftscale filter and it has its origin set to 
(0,0,0) and its spacing set to (1,1,1).  Below I have listed the part of 
my code in which I use the adaptor.  Could someone Please help to ensure 
that the origin and spacing of the output of the shiftscale image filter 
are correctly set.  I am aware that using the NthElementImageAdaptor may 
not be the easiest approach and am open to suggestions.

Thanks

Michael





typedef itk::NthElementImageAdaptor<
        VectorFieldType,VectorFieldType::PixelType::ValueType>        
            VectorImageAdaptorType;
   
    ...
   
    VectorImageAdaptorType::Pointer vectorAcessor = 
VectorImageAdaptorType::New();

   
    typedef itk::ShiftScaleImageFilter< VectorImageAdaptorType, 
TensorInternalType > ShiftScaleFilterType;
    ShiftScaleFilterType::Pointer shiftFilter = ShiftScaleFilterType::New();
   
    for(int r = 0;r<5;r++)
    {
        for(int c = 0; c<3;c++)
        {
           
            ...
           
            vectorAcessor->SetImage(vectorInput[r]);
            vectorAcessor->SelectNthElement(c);
            vectorAcessor->Update();
            vectorAcessor->SetSpacing(vectorInput[r]->GetSpacing());
            vectorAcessor->SetOrigin(vectorInput[r]->GetOrigin());
           
            shiftFilter->SetInput( vectorAcessor );
            shiftFilter->Update();

            ...
           
            
extendHalfPixel(shiftFilter->GetOutput(),tensorInternal[r][c].GetPointer(),lInterpolator.GetPointer());
        }

    }

-- 
Michael Hardisty
M.A.Sc Student
University of Toronto
Orthopaedic Biomechanics Laboratory
Sunnybrook & Women's College Health Sciences Centre




More information about the Insight-users mailing list