[Insight-developers] How to cast the itk::Image<PixelType, 3> * to itk::Image<itk::VariableLengthVector<PixelType>, 3> *

Binjie Qin bjqin at sjtu.edu.cn
Wed Jan 27 22:43:40 EST 2010


Dear Luis:

    We follow your advice by using the ImageToVectorImageFilter to convert  
"itk::Image<PixelType, 3>*" to  
"itk::Image<itk::VariableLengthVector<PixelType>, 3>*", those codes are:

    typedef itk::Image<PixelType,2>        ScalarImageType;
    typedef itk::ImageToVectorImageFilter<ScalarImageType> FilterType;
    FilterType::Pointer filter = FilterType::New();

    typedef  
itk::VectorIndexSelectionCastImageFilter<NrrdImageType,IndexImageType>  
FixedImageType;
    FixedImageType::Pointer fixedImageExtractionFilter =  
FixedImageType::New();
    .
    .
    .

    filter->SetInput(0,fixedImageExtractionFilter->GetOutput( ));
    filter->Update();

    typedef itk::VectorImageRegisterVersorRigidFilter<NrrdImageType,  
NrrdImageType> RegisterFilterType;
    RegisterFilterType::Pointer registerImageFilter =  
RegisterFilterType::New();
     .
     .
     .

    registerImageFilter->SetFixedImage( filter->GetOutput());

    However, the last line code still results in the same conversion error:  
error C2664:  
'itk::VectorImageRegisterVersorRigidFilter<TInputImage,TOutputImage>::SetFixedImage'  
: cannot convert parameter 1 from  
'itk::VectorImage<TPixel,VImageDimension> *' to  
'itk::Image<TPixel,VImageDimension> *'
1>        with
1>        [
1>            TInputImage=NrrdImageType,
1>            TOutputImage=NrrdImageType
1>        ]
1>        and
1>        [
1>            TPixel=PixelType,
1>            VImageDimension=3
1>        ]
1>        and
1>        [
1>            TPixel=itk::VariableLengthVector<PixelType>,
1>            VImageDimension=3
1>        ]
1>        Types pointed to are unrelated; conversion requires  
reinterpret_cast, C-style cast or function-style cast







On Tue, 26 Jan 2010 23:18:18 +0800, Luis Ibanez <luis.ibanez at kitware.com>  
wrote:

> Hi bjqin at SJTU,
>
>
> You may want to use the filter:
>
> Insight/Code/BasicFilters/
>       itkImageToVectorImageFilter.h
>
>
>    Regards,
>
>
>         Luis
>
>
>
> ------------------------------------
> On Mon, Jan 25, 2010 at 10:44 PM, Binjie Qin <bjqin at sjtu.edu.cn> wrote:
>> Dear insight-developers:
>>
>>   There is PixelType (typedef signed short PixelType) conversion error  
>> of
>> building gtractCoregBvalues at the GTRACT in the following code:
>>
>>   typedef
>> itk::VectorIndexSelectionCastImageFilter<NrrdImageType,IndexImageType>
>> FixedImageType;
>>   FixedImageType::Pointer fixedImageExtractionFilter =
>> FixedImageType::New();
>>    .
>>    .
>>    .
>>
>>   typedef itk::VectorImageRegisterVersorRigidFilter<NrrdImageType,
>> NrrdImageType> RegisterFilterType;
>>    RegisterFilterType::Pointer registerImageFilter =
>> RegisterFilterType::New();
>>    .
>>    .
>>    .
>>
>>    registerImageFilter->SetFixedImage(
>> fixedImageExtractionFilter->GetOutput( ) );
>>
>>
>>    The outputimage PixelType of "fixedImageExtractionFilter->GetOutput(  
>> )"
>> is TPixel=PixelType, PixelType is signed short.
>>
>>    However the inputimage PixelType of  
>> "registerImageFilter->SetFixedImage
>> (itk::Image<TPixel,VImageDimension> *)" is
>> TPixel=itk::VariableLengthVector<PixelType>
>>
>>    How to cast the "itk::Image<PixelType,3> *" to
>> "itk::Image<itk::VariableLengthVector<PixelType>,3> *"?
>>
>>    The itkScalarToArrayCastImageFilter is not useful because the
>> VariableLengthVector<PixelType> is not a fixed array .
>>
>>    If the cast should be implemented with static_cast of each PixelType  
>> by
>> accessing each pixel value?
>>
>>
>>    Thank you in advance.
>>
>>
>> bjqin at SJTU
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
>
> __________ Information from ESET NOD32 Antivirus, version of virus  
> signature database 4805 (20100125) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>


-- 
Binjie Qin, Ph.D.
Associate Professor
Dept. of Biomedical Engineering
Shanghai Jiao Tong University
800 Dongchuan Road, Min Hang
Shanghai, P. R. China, 200240
Phone: 86-21-34204382,86-138-1635-5349
Fax: 86-21-34205709
Email:bjqin at sjtu.edu.cn


More information about the Insight-developers mailing list