[Insight-users] using spatialObjects in ManagedITK

Shady Shidfar shady_shidfar at yahoo.com
Tue Jul 22 10:06:14 EDT 2008





----- Forwarded Message ----
From: Shady Shidfar <shady_shidfar at yahoo.com>
To: Dan Mueller <dan.muel at gmail.com>
Sent: Tuesday, 22 July, 2008 2:36:37 PM
Subject: Re: [Insight-users] using spatialObjects in ManagedITK


Hi Dan, 
 
Thanks for the file, I guess I'll wait for you to solve the problem :-). Now instead of using SpatialObjects I'm trying to use itkPolyLineParametricPath  to draw contours on my image, then use itkPathToImageFilter to display them on the image. The problem is that I get a weird message. Could you please have a look at the following code and see what the problem is. 
the error is: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 
 usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Windows.Forms;namespace
{InteractiveHierarchicalSegmentationDotNetstaticclassProgram{///<summary>///The main entry point for the application.///</summary>[
{STAThread]staticvoidMain()//Application.EnableVisualStyles();//Application.SetCompatibleTextRenderingDefault(false);//Application.Run(new Form1());}
}
}Application.Run(newTestForm());
 
 
 
 usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingvtk;usingitk;namespace
{InteractiveHierarchicalSegmentationDotNetpublicpartialclassTestForm: Form{
{
InitializeComponent();publicTestForm()try{// Read ITK imageinputImage.Read(
inputImage.DisconnectPipeline();itkImage_UC3inputImage = itkImage_UC3.New();"C:/brain.tif");// Import ITK image to VTKitk2vtk.SetInput(inputImage);
itk2vtk.Update();
actor.SetInput(data);
vtkRenderer1.AddActor(actor);
 itkImageToVTKImageFilteritk2vtk =itkImageToVTKImageFilter.New(inputImage);vtkImageDatadata = itk2vtk.GetOutput();vtkImageActoractor = newvtkImageActor();Console.WriteLine(actor.ToString());vtkRenderervtkRenderer1 = newvtkRenderer();this.vtkFormsWindowControl1.GetRenderWindow().AddRenderer(vtkRenderer1);// define and display a pathitkPointorigin = inputImage.Origin; 
point[0] = origin[0] + spacing[0] * size[0];
point[1] = origin[1] + spacing[1] * size[1];itkSpacingspacing = inputImage.Spacing;itkSizesize = inputImage.Size;itkPointpoint = newitkPoint(3);itkPolyLineParametricPath_3path = itkPolyLineParametricPath_3.New();//point[3] = origin[2] + spacing[2] * size[2];inputImage.TransformPhysicalPointToContinuousIndex(origin, 
path.AddVertex(cindex);
inputImage.TransformPhysicalPointToContinuousIndex(point, 
path.AddVertex(cindex);
path2ImageFilter.SetInput(path);
path2ImageFilter.PathValue = 200;
path2ImageFilter.GetOutput(inputImage);
}
{
}
}
}
}
 
 
I can send you the whole project if it helps.
 
Cheers, Shaady
 
 itkContinuousIndexcindex = newitkContinuousIndex(3);outcindex);outcindex);itkPathToImageFilter_PLPP3IUC3path2ImageFilter = itkPathToImageFilter_PLPP3IUC3.New();catch(Exceptionex)Console.WriteLine(ex);



----- Original Message ----
From: Dan Mueller <dan.muel at gmail.com>
To: Shady Shidfar <shady_shidfar at yahoo.com>
Sent: Friday, 18 July, 2008 3:21:07 PM
Subject: Re: [Insight-users] using spatialObjects in ManagedITK

Hi Shady,

SpatialObjects are a whole separate part of ITK, take for example the
SpatialObjectPoint class which is a whole new entity. Because the
wrapping used by ManagedITK is not automated, infrastructure (in the
form of type and wrapper templates) must be provided. Wrapping
SpatialObjects requires a whole new set of infrastructure classes
which I have not had time to implement yet. Some of the classes were
easy to wrap and therefore have been done so. The other classes (like
BlobSpatialObject) are more complex and have not been done. In
summary: it is not quick and easy to wrap these classes.

However, there is a (quick) hack which may help you. TubeSpatialObject
is also rather complex, but I have managed to hack together a wrapper.
If you open "managed_itkTubeSpatialObject.cmake" you will see a lot of
hacked code. You can do something similar with BlobSpatialObject.

I have attached a file which should get you started. I have *not*
configured/compiled this file; there ==WILL== be errors. The
SetPoints() method is just a rough guess I quick slapped together in
notepad... Like I said, this is a hack until I get the time to do it
properly.

I might be able to take a look at the issue myself in the coming
weeks, but I am really busy at the moment. Hopefully this will be
enough to get you started if you really really need it...

Regards, Dan

2008/7/18 Shady Shidfar <shady_shidfar at yahoo.com>:
> Thanks Dan,
> So is there anyway to wrap them myself them and add them to manageITK?
>
> thanks
> Shady
> ----- 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: Tuesday, 15 July, 2008 2:29:19 PM
> Subject: Re: [Insight-users] using spatialObjects in ManagedITK
>
> Hi Shady,
>
> Unfortunately ManagedITK does not yet wrap all SpatialObjects. The
> following *are* wrapped:
>  itkEllipseSpatialObject
>  itkGroupSpatialObject
>  itkPlaneSpatialObject
>  itkSceneSpatialObject
>  itkSpatialObject
>  itkSpatialObjectReader
>  itkSpatialObjectWriter
>  itkTubeSpatialObject
>  itkTubeSpatialObjectPoint
>
> Sorry for the bad news.
>
> Regards, dan
>
> 2008/7/15 Shady Shidfar <shady_shidfar at yahoo.com>:
>> Hi Dan,
>>
>>
>>
>> I'm having a problem with spatial objects.I need to draw objects on my
>> image
>> so decided to work with itkSpacialObjects. I am trying  to get the
>> following
>> C++ code to work with managedITK, but I can't find itkBlobSpatialObject
>> and
>> itkSpatialObjectPoint.
>>
>>
>>
>> I've added ManagedITK.SpatialObjects and ManagedITK.Common as reference.
>> Are
>> they enough?
>>
>>
>>
>> Thanks for your help
>>
>> Shaady
>>
>>
>>
>> #if
>>
>> defined(_MSC_VER)
>>
>> #pragma
>>
>> warning ( disable : 4786 )
>>
>> #endif
>>
>>
>>
>> #include
>>
>> "itkBlobSpatialObject.h"
>>
>>
>>
>> #include
>>
>> "itkSpatialObjectPoint.h"
>>
>> // Software Guide : EndCodeSnippet
>>
>> int
>>
>> main( int, char *[] )
>>
>> {
>>
>> typedef itk::BlobSpatialObject<3> BlobType;
>>
>> typedef BlobType::Pointer BlobPointer;
>>
>> typedef itk::SpatialObjectPoint<3> BlobPointType;
>>
>>
>>
>> BlobType::PointListType list;
>>
>> for( unsigned int i=0; i<4; i++)
>>
>> {
>>
>> BlobPointType p;
>>
>> p.SetPosition(i,i+1,i+2);
>>
>> p.SetRed(1);
>>
>> p.SetGreen(0);
>>
>> p.SetBlue(0);
>>
>> p.SetAlpha(1.0);
>>
>> list.push_back(p);
>>
>> }
>>
>>
>>
>> BlobPointer blob = BlobType::New();
>>
>> blob->GetProperty()->SetName(
>>
>> "My Blob");
>>
>> blob->SetId(1);
>>
>> blob->SetPoints(list);
>>
>>
>>
>> BlobType::PointListType pointList = blob->GetPoints();
>>
>> std::cout <<
>>
>> "The blob contains " << pointList.size();
>>
>> std::cout <<
>>
>> " points" << std::endl;
>>
>>
>>
>> BlobType::PointListType::const_iterator it = blob->GetPoints().begin();
>>
>> while(it != blob->GetPoints().end())
>>
>> {
>>
>> std::cout <<
>>
>> "Position = " << (*it).GetPosition() << std::endl;
>>
>> std::cout <<
>>
>> "Color = " << (*it).GetColor() << std::endl;
>>
>> it++;
>>
>> }
>>
>>
>>
>> return 0;
>>
>> }
>>
>> ________________________________
>> Not happy with your email address?
>> Get the one you really want - millions of new email addresses available
>> now
>> at Yahoo!
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
> ________________________________
> Not happy with your email address?
> Get the one you really want - millions of new email addresses available now
> at Yahoo!

________________________________
Not happy with your email address? 
Get the one you really want - millions of new email addresses available now at Yahoo!


      __________________________________________________________
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080722/2e96bd0c/attachment-0001.htm>


More information about the Insight-users mailing list