[Insight-users] managedITK, converting itkImage to vtkImage
Dan Mueller
dan.muel at gmail.com
Mon Jul 14 02:26:41 EDT 2008
Hi Shady,
1. Great to hear you successfully compiled ManagedITK. ManagedITK.VTK
is not included in the main source because it depends on VTK. I don't
want to enforce this dependency for all users of ManagedITK, so
ManagedITK.VTK is located in the Examples/ExternalProjects/VTK folder
and must be compiled separately. Please follow the compilation steps
described in Examples/ExternalProjects/VTK/Readme.txt.
2. Unforunately I'm not a VTK guru, so your vtkImageActor problem is
outside of my realm of experience. My only piece of advice is to try a
signed pixel type. Simply use a cast or rescale filter to achieve
this.
Hope this helps.
Regards, Dan
2008/7/13 Shady Shidfar <shady_shidfar at yahoo.com>:
> Hi Dan,
> Thanks for all your help.
>
> 1- I compiled and built ManagedITK 3.6.0.2 without any errors but the
> problem is that there hasn't been a ManagedITK.VTK.dll created. So I get the
> error "The type or namespace name 'itkImageToVTKImageFilter' could not be
> found (are you missing a using directive or an assembly reference?)"
> Would you please tell me what I should do?
> 2- would you please check this piece of code, the piece of code you sent me
> works perfect. I just added the lines to show the image using vtkDotNet. I
> guess the problem is that vtkImageActor can't have unsigned data as input.
> Do you have any solution for this?
>
>
> using
>
> System;
>
> using
>
> System.Collections.Generic;
>
> using
>
> System.ComponentModel;
>
> using
>
> System.Data;
>
> using
>
> System.Drawing;
>
> using
>
> System.Linq;
>
> using
>
> System.Text;
>
> using
>
> System.Windows.Forms;
>
> using
>
> vtk;
>
> using
>
> itk;
>
>
>
> namespace
>
> InteractiveHierarchicalSegmentationDotNet
>
> {
>
> public partial class TestForm : Form
>
> {
>
> public TestForm()
>
> {
>
> InitializeComponent();
>
> try
>
> {
>
> // Read ITK image
>
> itkImage_SS3 input = itkImage_SS3.New();
>
> input.Read(
>
> "D:/brain.tif");
>
> 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());
>
> vtkRenderer vtkRenderer1 = new vtkRenderer();
>
> this.vtkFormsWindowControl1.GetRenderWindow().AddRenderer(vtkRenderer1);
>
> vtkRenderer1.AddActor(actor);
>
> }
>
> catch (Exception ex)
>
> {
>
> Console.WriteLine(ex);
>
> }
>
> }
>
> }
>
> }
>
> Thanks so much in advance
>
> Shaady
>
> ----- Original Message ----
> From: Dan Mueller <dan.muel at gmail.com>
> To: Shady Shidfar <shady_shidfar at yahoo.com>
> Cc: insight users <insight-users at itk.org>
> Sent: Thursday, 3 July, 2008 6:44:45 PM
> Subject: Re: [Insight-users] managedITK, converting itkImage to vtkImage
>
> 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);
> }
> }
> }
> }
>
> ________________________________
> Not happy with your email address?
> Get the one you really want - millions of new email addresses available now
> at Yahoo!
More information about the Insight-users
mailing list