<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">----- Forwarded Message ----<BR>From: Shady Shidfar <shady_shidfar@yahoo.com><BR>To: Dan Mueller <dan.muel@gmail.com><BR>Sent: Tuesday, 22 July, 2008 2:36:37 PM<BR>Subject: Re: [Insight-users] using spatialObjects in ManagedITK<BR><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV>Hi Dan, </DIV>
<DIV> </DIV>
<DIV>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 <FONT color=#2b91af size=2><FONT color=#2b91af size=2><FONT size=3>itkPolyLineParametricPath</FONT> </FONT></FONT> 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.<FONT color=#2b91af size=2><FONT color=#2b91af size=2>
<P> </P>
<P><FONT color=#000000 size=3>the error is: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</FONT> </P>
<P> </P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Collections.Generic;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Linq;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Windows.Forms;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>namespace</FONT></FONT><FONT size=2><FONT color=#000000> InteractiveHierarchicalSegmentationDotNet</FONT></P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>static</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>class</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Program</P></FONT></FONT><FONT size=2>
<P>{</P>
<P></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> </FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2><summary></P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> The main entry point for the application.</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> </FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2></summary></P></FONT></FONT><FONT size=2>
<P>[</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>STAThread</FONT></FONT><FONT size=2>]</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>static</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>void</FONT></FONT><FONT size=2> Main()</P>
<P>{</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>//Application.EnableVisualStyles();</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>//Application.SetCompatibleTextRenderingDefault(false);</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>//Application.Run(new Form1());</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Application</FONT></FONT><FONT size=2>.Run(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>TestForm</FONT></FONT><FONT size=2>());</P>
<P>}</P>
<P>}</P>
<P>}</P></FONT>
<P> </P>
<P> </P>
<P> </P>
<P> </P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Collections.Generic;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.ComponentModel;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Data;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Drawing;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Linq;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Text;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> System.Windows.Forms;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> vtk;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>using</FONT></FONT><FONT size=2><FONT color=#000000> itk;</FONT></P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>namespace</FONT></FONT><FONT size=2><FONT color=#000000> InteractiveHierarchicalSegmentationDotNet</FONT></P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>public</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>partial</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>class</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>TestForm</FONT></FONT><FONT size=2> : </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Form</P></FONT></FONT><FONT size=2>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>public</FONT></FONT><FONT size=2> TestForm()</P>
<P>{</P>
<P>InitializeComponent();</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>try</P></FONT></FONT><FONT size=2>
<P>{</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Read ITK image</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImage_UC3</FONT></FONT><FONT size=2> inputImage = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImage_UC3</FONT></FONT><FONT size=2>.New();</P>
<P>inputImage.Read(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"C:/brain.tif"</FONT></FONT><FONT size=2>);</P>
<P>inputImage.DisconnectPipeline();</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Import ITK image to VTK</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImageToVTKImageFilter</FONT></FONT><FONT size=2> itk2vtk =</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkImageToVTKImageFilter</FONT></FONT><FONT size=2>.New(inputImage);</P>
<P>itk2vtk.SetInput(inputImage);</P>
<P>itk2vtk.Update();</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageData</FONT></FONT><FONT size=2> data = itk2vtk.GetOutput();</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageActor</FONT></FONT><FONT size=2> actor = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkImageActor</FONT></FONT><FONT size=2>();</P>
<P>actor.SetInput(data);</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Console</FONT></FONT><FONT size=2>.WriteLine(actor.ToString());</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkRenderer</FONT></FONT><FONT size=2> vtkRenderer1 = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>vtkRenderer</FONT></FONT><FONT size=2>();</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>this</FONT></FONT><FONT size=2>.vtkFormsWindowControl1.GetRenderWindow().AddRenderer(vtkRenderer1);</P>
<P>vtkRenderer1.AddActor(actor);</P>
<P> </P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// define and display a path</P></FONT></FONT><FONT size=2>
<P></FONT>
<P><FONT color=#008000 size=2><FONT color=#008000 size=2></P></FONT></FONT><FONT size=2></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkPoint</FONT></FONT><FONT size=2> origin = inputImage.Origin;
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkSpacing</FONT></FONT><FONT size=2> spacing = inputImage.Spacing;</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkSize</FONT></FONT><FONT size=2> size = inputImage.Size;</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkPoint</FONT></FONT><FONT size=2> point = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkPoint</FONT></FONT><FONT size=2>(3);</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkPolyLineParametricPath_3</FONT></FONT><FONT size=2> path = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkPolyLineParametricPath_3</FONT></FONT><FONT size=2>.New();</P>
<P>point[0] = origin[0] + spacing[0] * size[0];</P>
<P>point[1] = origin[1] + spacing[1] * size[1];</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>//point[3] = origin[2] + spacing[2] * size[2];</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkContinuousIndex</FONT></FONT><FONT size=2> cindex = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkContinuousIndex</FONT></FONT><FONT size=2>(3);</P>
<P>inputImage.TransformPhysicalPointToContinuousIndex(origin, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>out</FONT></FONT><FONT size=2> cindex);</P>
<P>path.AddVertex(cindex);</P>
<P>inputImage.TransformPhysicalPointToContinuousIndex(point, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>out</FONT></FONT><FONT size=2> cindex);</P>
<P>path.AddVertex(cindex);</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkPathToImageFilter_PLPP3IUC3</FONT></FONT><FONT size=2> path2ImageFilter = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>itkPathToImageFilter_PLPP3IUC3</FONT></FONT><FONT size=2>.New();</P>
<P>path2ImageFilter.SetInput(path);</P>
<P>path2ImageFilter.PathValue = 200;</P>
<P>path2ImageFilter.GetOutput(inputImage);</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>catch</FONT></FONT><FONT size=2> (</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Exception</FONT></FONT><FONT size=2> ex)</P>
<P>{</P>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Console</FONT></FONT><FONT size=2>.WriteLine(ex);</P>
<P>}</P>
<P>}</P>
<P>}</P>
<P>}</P>
<P> </P>
<P> </P>
<P><FONT color=#000000 size=3>I can send you the whole project if it helps.</FONT></P>
<P><FONT color=#000000 size=3></FONT> </P>
<P><FONT color=#000000 size=3>Cheers, Shaady</FONT></P>
<P><FONT color=#000000 size=3></FONT> </P>
<P><FONT color=#000000 size=3></FONT> </P></FONT></FONT></FONT><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">----- Original Message ----<BR>From: Dan Mueller <dan.muel@gmail.com><BR>To: Shady Shidfar <shady_shidfar@yahoo.com><BR>Sent: Friday, 18 July, 2008 3:21:07 PM<BR>Subject: Re: [Insight-users] using spatialObjects in ManagedITK<BR><BR>Hi Shady,<BR><BR>SpatialObjects are a whole separate part of ITK, take for example the<BR>SpatialObjectPoint class which is a whole new entity. Because the<BR>wrapping used by ManagedITK is not automated, infrastructure (in the<BR>form of type and wrapper templates) must be provided. Wrapping<BR>SpatialObjects requires a whole new set of infrastructure classes<BR>which I have not had time to implement yet. Some of the classes were<BR>easy to wrap and therefore have been done so. The other classes (like<BR>BlobSpatialObject) are more complex and have not been done. In<BR>summary: it is not quick and easy to wrap these classes.<BR><BR>However,
there is a (quick) hack which may help you. TubeSpatialObject<BR>is also rather complex, but I have managed to hack together a wrapper.<BR>If you open "managed_itkTubeSpatialObject.cmake" you will see a lot of<BR>hacked code. You can do something similar with BlobSpatialObject.<BR><BR>I have attached a file which should get you started. I have *not*<BR>configured/compiled this file; there ==WILL== be errors. The<BR>SetPoints() method is just a rough guess I quick slapped together in<BR>notepad... Like I said, this is a hack until I get the time to do it<BR>properly.<BR><BR>I might be able to take a look at the issue myself in the coming<BR>weeks, but I am really busy at the moment. Hopefully this will be<BR>enough to get you started if you really really need it...<BR><BR>Regards, Dan<BR><BR>2008/7/18 Shady Shidfar <<A href="mailto:shady_shidfar@yahoo.com" target=_blank rel=nofollow
ymailto="mailto:shady_shidfar@yahoo.com">shady_shidfar@yahoo.com</A>>:<BR>> Thanks Dan,<BR>> So is there anyway to wrap them myself them and add them to manageITK?<BR>><BR>> thanks<BR>> Shady<BR>> ----- Original Message ----<BR>> From: Dan Mueller <<A href="mailto:dan.muel@gmail.com" target=_blank rel=nofollow ymailto="mailto:dan.muel@gmail.com">dan.muel@gmail.com</A>><BR>> To: Shady Shidfar <<A href="mailto:shady_shidfar@yahoo.com" target=_blank rel=nofollow ymailto="mailto:shady_shidfar@yahoo.com">shady_shidfar@yahoo.com</A>><BR>> Cc: insight users <<A href="mailto:insight-users@itk.org" target=_blank rel=nofollow ymailto="mailto:insight-users@itk.org">insight-users@itk.org</A>><BR>> Sent: Tuesday, 15 July, 2008 2:29:19 PM<BR>> Subject: Re: [Insight-users] using spatialObjects in ManagedITK<BR>><BR>> Hi Shady,<BR>><BR>> Unfortunately ManagedITK does not yet wrap all SpatialObjects.
The<BR>> following *are* wrapped:<BR>> itkEllipseSpatialObject<BR>> itkGroupSpatialObject<BR>> itkPlaneSpatialObject<BR>> itkSceneSpatialObject<BR>> itkSpatialObject<BR>> itkSpatialObjectReader<BR>> itkSpatialObjectWriter<BR>> itkTubeSpatialObject<BR>> itkTubeSpatialObjectPoint<BR>><BR>> Sorry for the bad news.<BR>><BR>> Regards, dan<BR>><BR>> 2008/7/15 Shady Shidfar <<A href="mailto:shady_shidfar@yahoo.com" target=_blank rel=nofollow ymailto="mailto:shady_shidfar@yahoo.com">shady_shidfar@yahoo.com</A>>:<BR>>> Hi Dan,<BR>>><BR>>><BR>>><BR>>> I'm having a problem with spatial objects.I need to draw objects on my<BR>>> image<BR>>> so decided to work with itkSpacialObjects. I am trying to get the<BR>>> following<BR>>> C++ code to work with managedITK, but I can't find
itkBlobSpatialObject<BR>>> and<BR>>> itkSpatialObjectPoint.<BR>>><BR>>><BR>>><BR>>> I've added ManagedITK.SpatialObjects and ManagedITK.Common as reference.<BR>>> Are<BR>>> they enough?<BR>>><BR>>><BR>>><BR>>> Thanks for your help<BR>>><BR>>> Shaady<BR>>><BR>>><BR>>><BR>>> #if<BR>>><BR>>> defined(_MSC_VER)<BR>>><BR>>> #pragma<BR>>><BR>>> warning ( disable : 4786 )<BR>>><BR>>> #endif<BR>>><BR>>><BR>>><BR>>> #include<BR>>><BR>>> "itkBlobSpatialObject.h"<BR>>><BR>>><BR>>><BR>>> #include<BR>>><BR>>> "itkSpatialObjectPoint.h"<BR>>><BR>>> // Software Guide : EndCodeSnippet<BR>>><BR>>> int<BR>>><BR>>> main( int, char *[] )<BR>>><BR>>> {<BR>>><BR>>> typedef
itk::BlobSpatialObject<3> BlobType;<BR>>><BR>>> typedef BlobType::Pointer BlobPointer;<BR>>><BR>>> typedef itk::SpatialObjectPoint<3> BlobPointType;<BR>>><BR>>><BR>>><BR>>> BlobType::PointListType list;<BR>>><BR>>> for( unsigned int i=0; i<4; i++)<BR>>><BR>>> {<BR>>><BR>>> BlobPointType p;<BR>>><BR>>> p.SetPosition(i,i+1,i+2);<BR>>><BR>>> p.SetRed(1);<BR>>><BR>>> p.SetGreen(0);<BR>>><BR>>> p.SetBlue(0);<BR>>><BR>>> p.SetAlpha(1.0);<BR>>><BR>>> list.push_back(p);<BR>>><BR>>> }<BR>>><BR>>><BR>>><BR>>> BlobPointer blob = BlobType::New();<BR>>><BR>>> blob->GetProperty()->SetName(<BR>>><BR>>> "My Blob");<BR>>><BR>>> blob->SetId(1);<BR>>><BR>>>
blob->SetPoints(list);<BR>>><BR>>><BR>>><BR>>> BlobType::PointListType pointList = blob->GetPoints();<BR>>><BR>>> std::cout <<<BR>>><BR>>> "The blob contains " << pointList.size();<BR>>><BR>>> std::cout <<<BR>>><BR>>> " points" << std::endl;<BR>>><BR>>><BR>>><BR>>> BlobType::PointListType::const_iterator it = blob->GetPoints().begin();<BR>>><BR>>> while(it != blob->GetPoints().end())<BR>>><BR>>> {<BR>>><BR>>> std::cout <<<BR>>><BR>>> "Position = " << (*it).GetPosition() << std::endl;<BR>>><BR>>> std::cout <<<BR>>><BR>>> "Color = " << (*it).GetColor() << std::endl;<BR>>><BR>>> it++;<BR>>><BR>>> }<BR>>><BR>>><BR>>><BR>>> return 0;<BR>>><BR>>>
}<BR>>><BR>>> ________________________________<BR>>> Not happy with your email address?<BR>>> Get the one you really want - millions of new email addresses available<BR>>> now<BR>>> at Yahoo!<BR>>> _______________________________________________<BR>>> Insight-users mailing list<BR>>> <A href="mailto:Insight-users@itk.org" target=_blank rel=nofollow ymailto="mailto:Insight-users@itk.org">Insight-users@itk.org</A><BR>>> <A href="http://www.itk.org/mailman/listinfo/insight-users" target=_blank rel=nofollow>http://www.itk.org/mailman/listinfo/insight-users</A><BR>>><BR>>><BR>><BR>> ________________________________<BR>> Not happy with your email address?<BR>> Get the one you really want - millions of new email addresses available now<BR>> at Yahoo!<BR></DIV></DIV></DIV><BR>
<HR SIZE=1>
Not happy with your email address? <BR><A href="http://uk.docs.yahoo.com/ymail/new.html" target=_blank rel=nofollow>Get the one you really want</A> - millions of new email addresses available now at <A href="http://uk.docs.yahoo.com/ymail/new.html" target=_blank rel=nofollow>Yahoo!</A></DIV></DIV></div><br>
<hr size=1>
Not happy with your email address?
<br> <a href="http://uk.docs.yahoo.com/ymail/new.html"> Get the one you
really want</a> - millions of new email addresses available now at <a
href="http://uk.docs.yahoo.com/ymail/new.html"> Yahoo!</a></body></html>