[Insight-users] managedITK, converting itkImage to vtkImage

Dan Mueller dan.muel at gmail.com
Thu Jul 3 13:44:45 EDT 2008


Hi Shady,

My responses inline below.

2008/7/3 Shady Shidfar <shady_shidfar at yahoo.com>:
> Hi everyone, I need help with managedITK(ITK .net). I've just started using
> managedITK instead of using ITK, c++ and FLTK and it's very very cool. I
> hope I won't need to go back to FLTK anymore.

I'm glad it's helpful. I too find Windows Forms development much
easier (at the expense of cross platform support). Perhaps you could
leave a review at the Insight Journal:
    http://www.insight-journal.org/InsightJournalManager/view_reviews.php?pubid=151

You may also be interested to know I recently uploaded a new version
(3.6.0.2). It includes a number of important changes, so you may want
to check it out before you get too far. The Insight Journal submission
system can't handle large files, so I've only uploaded the source for
this version (I may have to consider moving to Google Code or
Sourceforge to make the pre-compiled assemblies available).

> Anyway I'm trying to read an
> image , create an itkImage, export it to VTK and then view it. Everything's
> fine when I have a unsigned char itkImage (itkImage_UC3)  and accordingly
> itkImageToVTKImageFilter_IUC3 but when I change the image and filter into
> signed type;
>
> itkImage_SS3 and
>
> itkImageToVTKImageFilter_ISS3, I get the error :
>
>
>
> ERROR: In m:\dev\cur\vtkdotnet\branch\50\Rendering\vtkImageActor.cxx, line
> 182
> vtkOpenGLImageActor (064064D8): This filter requires unsigned char scalars
> as input
>
> Does anyone know what's the problem and how can I have a unsigned image and
> convert it to vtkImage using ManagedITK and VTK.net ofcourse?

I can't reproduce your problem. Can you please provide a minimal
example? Here is the minimal example I was trying:

using System;
using itk;
using vtk;

namespace ItkVtkTest
{
    static class ItkVtkTest
    {
        [STAThread]
        static void Main()
        {
            try
            {
                //  Read ITK image
                itkImage_SS3 input = itkImage_SS3.New();
                input.Read("D:/Temp/engine.mhd");
                input.DisconnectPipeline();

                // Import ITK image to VTK
                itkImageToVTKImageFilter itk2vtk =
                    itkImageToVTKImageFilter.New(input);
                itk2vtk.SetInput(input);
                itk2vtk.Update();
                vtkImageData data = itk2vtk.GetOutput();

                vtkImageActor actor = new vtkImageActor();
                actor.SetInput(data);
                Console.WriteLine(actor.ToString());

                // Clean up
                actor.Dispose();
                itk2vtk.Dispose();
                input.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }
}


More information about the Insight-users mailing list