<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>
<BR><FONT size=2>
</FONT><FONT face="" color=#000000 size=2>typedef</FONT><FONT face="" size=2><FONT color=#000000> itk::GaussianSpatialObject< 2 > GaussianType;</FONT><BR>
</FONT><FONT color=#000000><FONT face="" size=2>typedef</FONT><FONT face="" size=2> itk::GroupSpatialObject< 2 > 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 < 10; i++)</FONT><BR>
<FONT color=#000000>{</FONT></FONT><FONT face="" size=2><BR>
<FONT color=#000000>gaussianObject->GetObjectToParentTransform()->SetOffset(i * 30);</FONT><BR>
<FONT color=#000000>gaussianObject->ComputeObjectToWorldTransform();</FONT><BR>
<BR>
<FONT color=#000000>group->AddSpatialObject(gaussianObject);</FONT><BR>
<FONT color=#000000>}</FONT><BR>
<FONT color=#000000></FONT> <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 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 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>> Ali,<BR>> <BR>> If you are creating a 2D image, you have to make the dimension of the <BR>> GaussianSpatialObject of dimension 2:<BR>> <BR>> typedef itk::GaussianSpatialObject< 2 > GaussianType;<BR>> <BR>> This should solve your problem with the corrupted size.<BR>> <BR>> Also, if you want to put your gaussian at a specific location (in world <BR>> coordinate). Let's say at (100,100)mm. You can do something like:<BR>> <BR>> gaussianObject->GetObjectToParentTransform()->SetOffsetComponent(100);<BR>> gaussianObject->ComputeObjectToWorldTransform();<BR>> <BR>> Hope that helps,<BR>> <BR>> Julien<BR>> <BR>> Ali - wrote:<BR>> > Gaetan,<BR>> > <BR>> > I have tried SpatialObjectToImageFilter as explained in the ITK software guide ending up with this error:<BR>> > <BR>> > stack around the variable 'size' was corrupted.<BR>> > <BR>> > 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>> > <BR>> > ----------------------------------------------------------<BR>> > <BR>> > #if defined(_MSC_VER)<BR>> > #pragma warning ( disable : 4786 )<BR>> > #endif<BR>> > <BR>> > #include "itkImage.h"<BR>> > #include "itkGaussianSpatialObject.h"<BR>> > #include "itkGroupSpatialObject.h"<BR>> > #include "itkSpatialObjectToImageFilter.h"<BR>> > <BR>> > #include "itkImageToVTKImageFilter.h"<BR>> > #include "vtkImageViewer.h"<BR>> > #include "vtkRenderWindowInteractor.h"<BR>> > <BR>> > int main(int, char *[])<BR>> > {<BR>> > const unsigned int ParticleImageCount = 1;<BR>> > <BR>> > typedef unsigned char PixelType;<BR>> > const unsigned int Dimension = 2;<BR>> > <BR>> > typedef itk::Image< PixelType, Dimension > ImageType;<BR>> > typedef itk::GaussianSpatialObject< 3 > GaussianType;<BR>> > typedef itk::SpatialObjectToImageFilter< GaussianType, ImageType > SpatialObjectToImageFilterType;<BR>> > <BR>> > GaussianType::Pointer gaussianObject = GaussianType::New();<BR>> > gaussianObject->SetMaximum(2);<BR>> > gaussianObject->SetRadius(5);<BR>> > <BR>> > ImageType::SizeType size;<BR>> > size[0] = 200;<BR>> > size[1] = 200;<BR>> > SpatialObjectToImageFilterType::Pointer imageFilter = SpatialObjectToImageFilterType::New();<BR>> > imageFilter->SetSize(size);<BR>> > <BR>> > imageFilter->SetInput(gaussianObject);<BR>> > imageFilter->Update();<BR>> > <BR>> > ImageType::Pointer pImage = imageFilter->GetOutput();<BR>> > <BR>> > typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;<BR>> > ConnectorType::Pointer connector = ConnectorType::New();<BR>> > connector->SetInput( pImage );<BR>> > vtkImageViewer* viewer = vtkImageViewer::New();<BR>> > vtkRenderWindowInteractor* renderWindowInteractor = vtkRenderWindowInteractor::New();<BR>> > viewer->SetupInteractor( renderWindowInteractor);<BR>> > viewer->SetInput( connector->GetOutput() );<BR>> > viewer->Render();<BR>> > viewer->SetColorWindow( 255);<BR>> > viewer->SetColorLevel( 128);<BR>> > renderWindowInteractor->Start();<BR>> > <BR>> > return 0;<BR>> > }<BR>> > <BR>> > <BR>> > _________________________________________________________________<BR>> > Be one of the first to try Windows Live Mail.<BR>> > http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d_______________________________________________<BR>> > Insight-users mailing list<BR>> > Insight-users@itk.org<BR>> > http://www.itk.org/mailman/listinfo/insight-users<BR>> > <BR>> <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>