[Insight-users] vtk to itk

Luis Ibanez luis.ibanez@kitware.com
Wed, 10 Apr 2002 09:44:32 -0400


Hi Siddhartha,


One of the drawback of templated code is that error messages
can easily become quite long.  We use to edit the error messages
in order to aling the types. In your case that will result in:

   'SetInput' cannot convert parameter 1 from :

  itk::SmartPointer<class itk::Image<unsigned long,2, ...>

            to

  itk::Image<float,2,... > *

---

It seems that you are attempting to pass the SmartPoiter of
an Image<unsigned long,2>  to a raw pointer of a Image<float,2>.

There are two different problems with that:

1) If you want to assign a SmartPointer to a raw pointer
    you need to call the method "GetPointer()" on the SmartPointer.

Let's say for example:

   SmartPointer< myClass >  mySmartPointer = myClass::New();
   myClass * myRawPointer = mySmartPointer.GetPointer();

that will extract the raw pointer to the first object and then
made a normal copy of the pointer into another raw pointer.

You can also opt for transfering the SmartPointer to another
SmartPointer like:

   SmartPointer< myClass >  mySmartPointer = myClass::New();
   SmartPointer< myClass >  mySecondSmartPointer = mySmartPointer;


2) The code in your example is attempting to assing a
    "unsigned long" image to a "float" image. Given that the
    pixel types of the images don't match you may want to
    reconsider the type of any of them or using a CastingFilter.

    If you are obtaining the first image from the ImageFileReader<>
    please note that this filter is capable of doing the casting
    for you at input time.  So even if the image stored in your
    file is of pixel type "usigned long" you can instantiate the
    ImageFileReader<> filter over Image<float>.  The filter will
    then do the conversion for you.  Note that these conversions
    are naive C-castings. If you want to adjust ranges of gray
    values, you may want to use the itk::ShiftScaleImageFilter
    which applies a linear transformation to the gray levels on
    the image.





Please let us know if any of these options help to solve
your problem.


Thanks


Luis


===========================================

Thyagarajan, Siddhartha (CORP, GEITC) wrote:
> hi,
>  how do i convert a vtk image to itk format...if i directly import the image
> and perform watershed filter test i get following error
> 
> 
> C:\Insight\Auxiliary\vtk\itkVTKtoITKtoVTK.cxx(178) : error C2664: 'SetInput'
> : cannot convert parameter 1 from 'class itk::SmartPointer<class
> itk::Image<unsigned long,2,class itk::DefaultImageTraits<unsigned
> long,2,class itk::ValarrayImageContainer<
> unsigned long,unsigned long> > > >' to 'class itk::Image<float,2,class
> itk::DefaultImageTraits<float,2,class itk::ValarrayImageContainer<unsigned
> long,float> > > *'
>         No user-defined-conversion operator available that can perform this
> conversion, or the operator cannot be called 
> 
> 
>>g  John F Welch Technology Centre
>>
> _____________________________________________________________________
> Siddhartha Thyagarajan                         EMail:
> Siddhartha.Thyagarajan@geind.ge.com
> Imaging Technology.                             Phone:  +91-80-8412050 Ext:
> 3622
> GE John F. Welch Technology Center    
> EPIP, Phase II, Hoodi Village, Whitefield Rd., Bangalore 560066, INDIA
> 
> 
> 
> 
> 
> "THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
> ADDRESSEE and may contain confidential and privileged information.
> If the reader of this message is not the intended recipient,
> you are notified that any dissemination, distribution or copy of this 
> communication is strictly Prohibited. 
> If you have received this message by error, please notify us 
> immediately, return the original mail to the sender and delete the 
> message from your system."
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>