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

Julien Jomier julien.jomier at kitware.com
Mon Jan 8 10:43:53 EST 2007


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
> 



More information about the Insight-users mailing list