[Insight-users] problem for ITKimage to VTKimage in managedITK in C# in Visual Studio 2008

Luis Ibanez luis.ibanez at kitware.com
Sun Apr 6 17:40:42 EDT 2008


Hi Han,

Please try invoking Print( std::cout ) (or its equivalent in C#)
in i2v.GetOutput() just after you call i2v.Update(), and let us
know what you get as output.


    Thanks


        Luis


------------------
Han Chunlei wrote:
> 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.
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list