[Insight-users] How to create a set of spatially distributed
images
Ali -
saveez at hotmail.com
Mon Jan 8 10:01:39 EST 2007
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
More information about the Insight-users
mailing list