[Insight-users] problem for ITKimage to VTKimage in managedITK in	C# in Visual Studio 2008
    Han Chunlei 
    Chunlei.Han at tyks.fi
       
    Fri Apr  4 02:55:46 EDT 2008
    
    
  
Hei, All,
 
I am a new user of ITK. I installed managedITK3.4.0.1 and tried to use
it C# in visual studio 2008. I tried to transfer an image data from ITK
to VTK using itkimagetovtkimagefilter. The problem is that I always get
the wrong message like:
 
Warning: in ..\...\Code\common\itkProcessObject.cxx, line 520
ImagetoVTKimageFilter(04db21e0):Output doesn't exist!
 
And debug information as:
ApplicationException was unhandled
Could not downcast pointer to native class
 
In the line of
View.SetInput(i2v.getOutput());
 
Any help is greatly appreciated.
 
Chunlei Han 
 
************************************************************************
***************************
 
The codes are as follows:
using vtk;
using itk;
using itk2vtk = itk.itkImageToVTKImageFilter;
 
                      //  build an image
            itk.itkImage_UC2 itkimg = itk.itkImage_UC2.New();
            itk.itkSize itksz = new itk.itkSize(128, 128);
            itk.itkIndex itkind = new itk.itkIndex(0, 0);
            itk.itkImageRegion region = new
itk.itkImageRegion(itksz,itkind);
 
            itkimg.SetRegions(region);
            itkimg.Allocate();
            itkimg.FillBuffer(128);
 
           // confirm the image
            string filename = @"c:\temp\test.jpg";
            itkimg.Write(filename);
            itk.itkImageInformation info =
itk.itkImageBase.ReadInformation(filename);
            Console.WriteLine("infor= " + info.Size.ToString());
 
           // transfer itkImage to VTKimage by itkImagetoVTKimageFilter
            itk2vtk i2v = itk2vtk.New("IUC2");
            i2v.SetInput(itkimg);
            i2v.Update();
            vtk.vtkImageViewer viewer = new vtkImageViewer();
            viewer.SetInput(i2v.GetOutput()); // always problem here.
 
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080404/4c5404fd/attachment-0001.htm>
    
    
More information about the Insight-users
mailing list