<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>Julien,<BR>
<BR>
It seems I pasted the wrong code, what I wanted to describe was that,<BR>
even with having GaussianType::New() inside the loop, the final image<BR>
shows only 1 gaussian object. So the code should be like:<BR>
<BR>
typedef itk::GaussianSpatialObject< 2 > GaussianType;<BR>typedef itk::GroupSpatialObject< 2 > GroupSpatialObjectType;<BR>GroupSpatialObjectType::Pointer group = GroupSpatialObjectType::New();<BR>for(unsigned int i = 0; i < 10; i++)<BR>{<BR>
GaussianType::Pointer gaussianObject = GaussianType::New();<BR> gaussianObject->GetObjectToParentTransform()->SetOffset(i * 30);<BR> gaussianObject->ComputeObjectToWorldTransform();<BR> <BR> group->AddSpatialObject(gaussianObject);<BR> }<BR>
<BR>
I even tried this with a vector of GroupSpatialObjectType::Pointer ending up<BR>
with the same result of only 1 gaussian object. Am I missing a call to a method<BR>
or something?<BR>
<BR>
Do you think if the new filter itkSpatialGaussianObjectToImageFilter could be<BR>
ready for this week or would it take a long time to develop it? Would it be available<BR>
from the CVS? I could give it a try if there is a similar filter to begin with.<BR>
<BR>
<BR>> Ali,<BR>> <BR>> You need to put the GaussianType::New() inside the loop so that a new <BR>> GaussianObject is created and added to the group at every iteration.<BR>> <BR>> The itkSpatialObjectToImageFilter is meant to be very generic and <BR>> therefore might be slow for this kind of computation. We might want to <BR>> create a new filter specific to the GaussianSpatialObject. If you want <BR>> to give it a try, go for it, otherwise let me know (I might be able to <BR>> work on it only after tomorrow though).<BR>> <BR>> Julien<BR>> <BR>> Ali - wrote:<BR>> > Julien,.<BR>> > <BR>> > Thanks, that does the job! However, if we want to add more than one <BR>> > gaussian object by<BR>> > adding them to a group, the group only points to one instance of a <BR>> > gaussian object:<BR>> > <BR>> > typedef itk::GaussianSpatialObject< 2 > GaussianType;<BR>> > typedef itk::GroupSpatialObject< 2 > GroupSpatialObjectType;<BR>> > GroupSpatialObjectType::Pointer group = GroupSpatialObjectType::New();<BR>> > for(unsigned int i = 0; i < 10; i++)<BR>> > {<BR>> > gaussianObject->GetObjectToParentTransform()->SetOffset(i * 30);<BR>> > gaussianObject->ComputeObjectToWorldTransform();<BR>> > <BR>> > group->AddSpatialObject(gaussianObject);<BR>> > }<BR>> > <BR>> > The above code can generate only 1 gaussian object. How is it possible <BR>> > to add a new<BR>> > one to the group where each of them have different properties? By the <BR>> > way, the use of<BR>> > this algorithms seems to be sort of slow, it takes about a second or two <BR>> > per gaussian<BR>> > object for a 512 x 512 image -- is it normal?<BR>> > <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 <BR>> > 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 <BR>> > filter. Here is the code (you can get rid of the VTK part if you dont <BR>> > 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 > <BR>> > 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 = <BR>> > 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 = <BR>> > 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>> > > > <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>> > ------------------------------------------------------------------------<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>> <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>