[Insight-users] How to create a set of spatially distributed images

Ali - saveez at hotmail.com
Mon Jan 8 11:28:38 EST 2007


Julien,.Thanks, that does the job! However, if we want to add more than one gaussian object by
adding them to a group, the group only points to one instance of a gaussian object:
 
typedef itk::GaussianSpatialObject< 2 > GaussianType;
typedef itk::GroupSpatialObject< 2 > GroupSpatialObjectType;
GroupSpatialObjectType::Pointer group = GroupSpatialObjectType::New();
for(unsigned int i = 0; i < 10; i++)
{
gaussianObject->GetObjectToParentTransform()->SetOffset(i * 30);
gaussianObject->ComputeObjectToWorldTransform();
 
group->AddSpatialObject(gaussianObject);
}
 
The above code can generate only 1 gaussian object. How is it possible to add a new
one to the group where each of them  have different properties? By the way, the use of
this algorithms seems to be sort of slow, it takes about a second or two per gaussian
object for a 512 x 512 image -- is it normal?
> Ali,> > If you are creating a 2D image, you have to make the dimension of the > GaussianSpatialObject of dimension 2:> > typedef itk::GaussianSpatialObject< 2 > GaussianType;> > This should solve your problem with the corrupted size.> > Also, if you want to put your gaussian at a specific location (in world > coordinate). Let's say at (100,100)mm. You can do something like:> > gaussianObject->GetObjectToParentTransform()->SetOffsetComponent(100);> gaussianObject->ComputeObjectToWorldTransform();> > Hope that helps,> > Julien> > Ali - wrote:> > Gaetan,> > > > I have tried SpatialObjectToImageFilter as explained in the ITK software guide ending up with this error:> > > > stack around the variable 'size' was corrupted.> > > > 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):> > > > ----------------------------------------------------------> > > > #if defined(_MSC_VER)> > #pragma warning ( disable : 4786 )> > #endif> > > > #include "itkImage.h"> > #include "itkGaussianSpatialObject.h"> > #include "itkGroupSpatialObject.h"> > #include "itkSpatialObjectToImageFilter.h"> > > > #include "itkImageToVTKImageFilter.h"> > #include "vtkImageViewer.h"> > #include "vtkRenderWindowInteractor.h"> > > > int main(int, char *[])> > {> > const unsigned int ParticleImageCount = 1;> > > > typedef unsigned char PixelType;> > const unsigned int Dimension = 2;> > > > typedef itk::Image< PixelType, Dimension > ImageType;> > typedef itk::GaussianSpatialObject< 3 > GaussianType;> > typedef itk::SpatialObjectToImageFilter< GaussianType, ImageType > SpatialObjectToImageFilterType;> > > > GaussianType::Pointer gaussianObject = GaussianType::New();> > gaussianObject->SetMaximum(2);> > gaussianObject->SetRadius(5);> > > > ImageType::SizeType size;> > size[0] = 200;> > size[1] = 200;> > SpatialObjectToImageFilterType::Pointer imageFilter = SpatialObjectToImageFilterType::New();> > imageFilter->SetSize(size);> > > > imageFilter->SetInput(gaussianObject);> > imageFilter->Update();> > > > ImageType::Pointer pImage = imageFilter->GetOutput();> > > > typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;> > ConnectorType::Pointer connector = ConnectorType::New();> > connector->SetInput( pImage );> > vtkImageViewer* viewer = vtkImageViewer::New();> > vtkRenderWindowInteractor* renderWindowInteractor = vtkRenderWindowInteractor::New();> > viewer->SetupInteractor( renderWindowInteractor);> > viewer->SetInput( connector->GetOutput() );> > viewer->Render();> > viewer->SetColorWindow( 255);> > viewer->SetColorLevel( 128);> > renderWindowInteractor->Start();> > > > return 0;> > }> > > > > > _________________________________________________________________> > Be one of the first to try Windows Live Mail.> > http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d_______________________________________________> > Insight-users mailing list> > Insight-users at itk.org> > http://www.itk.org/mailman/listinfo/insight-users> > > 
_________________________________________________________________
Be one of the first to try Windows Live Mail.
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070108/31c6fb85/attachment.htm


More information about the Insight-users mailing list