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

Binjie Qin bjqin at sjtu.edu.cn
Thu Jan 28 21:42:34 EST 2010


Dear Luis:

    The error is corrected by the new CVS version of the gtractCoregBvalues  
at the GTRACT.

    The new FixedImageType at the new  
VectorImageRegisterVersorRigidFilter<TInputImage,TOutputImage> is defined  
as:

    typedef TInputImage InputImageType;
    typedef typename InputImagePixelType::ComponentType  
InputImageVectorComponentType;

#if 0
   /* The pixel type of FixedImageType should be based on the
    * InputImageValueType. However, the Mac compiler 4.0.1
    * does not like this. Currently this is hardcoded
    */
   typedef itk::Image<signed short,3>  FixedImageType;
#else
//  typedef typename itk::Image<unsigned short,3>  FixedImageType;
   typedef typename itk::Image<InputImageVectorComponentType,3>   
FixedImageType;
#endif

   /*However, the previous definition of FixedImageType is:

   typedef typename InputImageType::ValueType	 InputImageValueType;
   typedef itk::Image<InputImageValueType,3>         FixedImageType;
    */


    Now the following code could be built in the VC 9.0 and ITK 3-16:

     typedef itk::VectorImage<PixelType,3>	      NrrdImageType;
    typedef  
itk::VectorImageRegisterVersorRigidFilter<NrrdImageType,NrrdImageType>  
RegisterFilterType;
    RegisterFilterType::Pointer registerImageFilter =  
RegisterFilterType::New();
    registerImageFilter->SetFixedImage(  
fixedImageExtractionFilter->GetOutput( ) );


    Thank you for your kindly help! and thanks Vincent Magnotta for the  
work of GTRACT.


Binjie







On Fri, 29 Jan 2010 04:57:58 +0800, Luis Ibanez <luis.ibanez at kitware.com>  
wrote:

> Hi Binjie,
>
>
> If you want to pass an itk::VectorImage as input to your filter:
>
>
> VectorImageRegisterVersorRigidFilter<TInputImage,TOutputImage>
>
>
> Then you MUST use
>
>                                   itk::VectorImage<>
>
> as the template argument of the VectorImageRegisterVersorRigidFilter.
>
>
> Right now you are, incorrectly, using
>
>                        NrrdImageType
>
> as the template arguments of
>
>
>> typedef itk::VectorImageRegisterVersorRigidFilter<NrrdImageType,
>> NrrdImageType> RegisterFilterType;
>
>
> That's the reason why the compiler tells you that it :
>
>
> : cannot convert parameter 1 from '
>
>              itk::VectorImage<TPixel,VImageDimension> > *
>
> to          itk::Image<TPixel,VImageDimension> *
>
>
> In your typedef of
>
>
>> typedef itk::VectorImageRegisterVersorRigidFilter<NrrdImageType,
>> NrrdImageType> RegisterFilterType;
>
>
> You are promising this filter to give it a NrrdImageType, as input,
> and instead you are giving it an itk::VectorImage.
>
>
> Please make your template instantiations consistent with
> your pipeline.
>
>
>       Regards,
>
>
>           Luis
>
>
> --------------------------------------------------------------------------------------------
> On Wed, Jan 27, 2010 at 10:43 PM, Binjie Qin <bjqin at sjtu.edu.cn> wrote:
>> 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
>>
>
> __________ Information from ESET NOD32 Antivirus, version of virus  
> signature database 4811 (20100127) __________
>
> 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