<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>Julien,.<BR><BR>Thanks, that does the job! However, if we want to add more than one gaussian object by<BR>
adding them to a group, the group only points to one instance of a gaussian object:<BR>
&nbsp;<BR><FONT size=2>
</FONT><FONT face="" color=#000000 size=2>typedef</FONT><FONT face="" size=2><FONT color=#000000> itk::GaussianSpatialObject&lt; 2 &gt; GaussianType;</FONT><BR>
</FONT><FONT color=#000000><FONT face="" size=2>typedef</FONT><FONT face="" size=2> itk::GroupSpatialObject&lt; 2 &gt; GroupSpatialObjectType;<BR></FONT></FONT><FONT size=2>
GroupSpatialObjectType::Pointer group = GroupSpatialObjectType::New();<BR></FONT><FONT size=2>
</FONT><FONT color=#000000><FONT size=2>for</FONT><FONT size=2>(</FONT><FONT size=2>unsigned</FONT><FONT size=2> </FONT><FONT face="" size=2>int</FONT></FONT><FONT face="" size=2><FONT color=#000000> i = 0; i &lt; 10; i++)</FONT><BR>
<FONT color=#000000>{</FONT></FONT><FONT face="" size=2><BR>
<FONT color=#000000>gaussianObject-&gt;GetObjectToParentTransform()-&gt;SetOffset(i * 30);</FONT><BR>
<FONT color=#000000>gaussianObject-&gt;ComputeObjectToWorldTransform();</FONT><BR>
&nbsp;<BR>
<FONT color=#000000>group-&gt;AddSpatialObject(gaussianObject);</FONT><BR>
<FONT color=#000000>}</FONT><BR>
<FONT color=#000000></FONT>&nbsp;<BR>
<FONT color=#000000>The above code can generate only 1 gaussian object. How is it possible to add a new</FONT><BR>
<FONT color=#000000>one to the group where each of them&nbsp; have different properties? By the way, the use of</FONT><BR>
<FONT face="" color=#000000>this algorithms seems to be sort of slow, it takes about&nbsp;a second or two per gaussian</FONT><BR>
<FONT face="" color=#000000>object for a 512 x 512 image -- is it normal?</FONT><BR>
</FONT><BR><BR><BR>&gt; Ali,<BR>&gt; <BR>&gt; If you are creating a 2D image, you have to make the dimension of the <BR>&gt; GaussianSpatialObject of dimension 2:<BR>&gt; <BR>&gt; typedef itk::GaussianSpatialObject&lt; 2 &gt; GaussianType;<BR>&gt; <BR>&gt; This should solve your problem with the corrupted size.<BR>&gt; <BR>&gt; Also, if you want to put your gaussian at a specific location (in world <BR>&gt; coordinate). Let's say at (100,100)mm. You can do something like:<BR>&gt; <BR>&gt; gaussianObject-&gt;GetObjectToParentTransform()-&gt;SetOffsetComponent(100);<BR>&gt; gaussianObject-&gt;ComputeObjectToWorldTransform();<BR>&gt; <BR>&gt; Hope that helps,<BR>&gt; <BR>&gt; Julien<BR>&gt; <BR>&gt; Ali - wrote:<BR>&gt; &gt; Gaetan,<BR>&gt; &gt; <BR>&gt; &gt; I have tried SpatialObjectToImageFilter as explained in the ITK software guide ending up with this error:<BR>&gt; &gt; <BR>&gt; &gt; stack around the variable 'size' was corrupted.<BR>&gt; &gt; <BR>&gt; &gt; I use visual studio 8 under xp. I have already set the size for the filter. Here is the code (you can get rid of the VTK part if you dont want to see the result):<BR>&gt; &gt; <BR>&gt; &gt; ----------------------------------------------------------<BR>&gt; &gt; <BR>&gt; &gt; #if defined(_MSC_VER)<BR>&gt; &gt; #pragma warning ( disable : 4786 )<BR>&gt; &gt; #endif<BR>&gt; &gt; <BR>&gt; &gt; #include "itkImage.h"<BR>&gt; &gt; #include "itkGaussianSpatialObject.h"<BR>&gt; &gt; #include "itkGroupSpatialObject.h"<BR>&gt; &gt; #include "itkSpatialObjectToImageFilter.h"<BR>&gt; &gt; <BR>&gt; &gt; #include "itkImageToVTKImageFilter.h"<BR>&gt; &gt; #include "vtkImageViewer.h"<BR>&gt; &gt; #include "vtkRenderWindowInteractor.h"<BR>&gt; &gt; <BR>&gt; &gt; int main(int, char *[])<BR>&gt; &gt; {<BR>&gt; &gt; const unsigned int ParticleImageCount = 1;<BR>&gt; &gt; <BR>&gt; &gt; typedef unsigned char PixelType;<BR>&gt; &gt; const unsigned int Dimension = 2;<BR>&gt; &gt; <BR>&gt; &gt; typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;<BR>&gt; &gt; typedef itk::GaussianSpatialObject&lt; 3 &gt; GaussianType;<BR>&gt; &gt; typedef itk::SpatialObjectToImageFilter&lt; GaussianType, ImageType &gt; SpatialObjectToImageFilterType;<BR>&gt; &gt; <BR>&gt; &gt; GaussianType::Pointer gaussianObject = GaussianType::New();<BR>&gt; &gt; gaussianObject-&gt;SetMaximum(2);<BR>&gt; &gt; gaussianObject-&gt;SetRadius(5);<BR>&gt; &gt; <BR>&gt; &gt; ImageType::SizeType size;<BR>&gt; &gt; size[0] = 200;<BR>&gt; &gt; size[1] = 200;<BR>&gt; &gt; SpatialObjectToImageFilterType::Pointer imageFilter = SpatialObjectToImageFilterType::New();<BR>&gt; &gt; imageFilter-&gt;SetSize(size);<BR>&gt; &gt; <BR>&gt; &gt; imageFilter-&gt;SetInput(gaussianObject);<BR>&gt; &gt; imageFilter-&gt;Update();<BR>&gt; &gt; <BR>&gt; &gt; ImageType::Pointer pImage = imageFilter-&gt;GetOutput();<BR>&gt; &gt; <BR>&gt; &gt; typedef itk::ImageToVTKImageFilter&lt;ImageType&gt; ConnectorType;<BR>&gt; &gt; ConnectorType::Pointer connector = ConnectorType::New();<BR>&gt; &gt; connector-&gt;SetInput( pImage );<BR>&gt; &gt; vtkImageViewer* viewer = vtkImageViewer::New();<BR>&gt; &gt; vtkRenderWindowInteractor* renderWindowInteractor = vtkRenderWindowInteractor::New();<BR>&gt; &gt; viewer-&gt;SetupInteractor( renderWindowInteractor);<BR>&gt; &gt; viewer-&gt;SetInput( connector-&gt;GetOutput() );<BR>&gt; &gt; viewer-&gt;Render();<BR>&gt; &gt; viewer-&gt;SetColorWindow( 255);<BR>&gt; &gt; viewer-&gt;SetColorLevel( 128);<BR>&gt; &gt; renderWindowInteractor-&gt;Start();<BR>&gt; &gt; <BR>&gt; &gt; return 0;<BR>&gt; &gt; }<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; _________________________________________________________________<BR>&gt; &gt; Be one of the first to try Windows Live Mail.<BR>&gt; &gt; http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d_______________________________________________<BR>&gt; &gt; Insight-users mailing list<BR>&gt; &gt; Insight-users@itk.org<BR>&gt; &gt; http://www.itk.org/mailman/listinfo/insight-users<BR>&gt; &gt; <BR>&gt; <BR><BR><br /><hr />Be one of the first to try  <a href='http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d' target='_new'>Windows Live Mail.</a></body>
</html>