[Insight-users] How to create a set of spatially distributed
images
Ali -
saveez at hotmail.com
Tue Jan 9 06:27:44 EST 2007
Julien,
It seems I pasted the wrong code, what I wanted to describe was that,
even with having GaussianType::New() inside the loop, the final image
shows only 1 gaussian object. So the code should be like:
typedef itk::GaussianSpatialObject< 2 > GaussianType;typedef itk::GroupSpatialObject< 2 > GroupSpatialObjectType;GroupSpatialObjectType::Pointer group = GroupSpatialObjectType::New();for(unsigned int i = 0; i < 10; i++){
GaussianType::Pointer gaussianObject = GaussianType::New(); gaussianObject->GetObjectToParentTransform()->SetOffset(i * 30); gaussianObject->ComputeObjectToWorldTransform(); group->AddSpatialObject(gaussianObject); }
I even tried this with a vector of GroupSpatialObjectType::Pointer ending up
with the same result of only 1 gaussian object. Am I missing a call to a method
or something?
Do you think if the new filter itkSpatialGaussianObjectToImageFilter could be
ready for this week or would it take a long time to develop it? Would it be available
from the CVS? I could give it a try if there is a similar filter to begin with.
> Ali,> > You need to put the GaussianType::New() inside the loop so that a new > GaussianObject is created and added to the group at every iteration.> > The itkSpatialObjectToImageFilter is meant to be very generic and > therefore might be slow for this kind of computation. We might want to > create a new filter specific to the GaussianSpatialObject. If you want > to give it a try, go for it, otherwise let me know (I might be able to > work on it only after tomorrow though).> > Julien> > Ali - wrote:> > 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>>
_________________________________________________________________
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/20070109/248efe16/attachment.html
More information about the Insight-users
mailing list