<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Julien,<br><br>Unfortunately, your code still generates the same problem here. Even <br>different values of SpatialObjectToImageFilter.SetSize() produces <br>different pixel distributions. Here is an example:<br><br>SpatialObjectToImageFilter.SetSize(15, 15): <br>http://i25.tinypic.com/5vnpmq_th.png<br>SpatialObjectToImageFilter.SetSize(15, 25): <br>http://i31.tinypic.com/hvnfph_th.png<br><br>If things work smoothly in C++, it could be a problem with the <br>development version of WrapITK, however, I do not get any warnings or <br>exceptions with windows+java. Maybe Gaetan can confirm this problem with <br>python and linux.<br><br><br>-Ali<br><br>Code:<br>        itkGaussianSpatialObject2 gaus = new itkGaussianSpatialObject2();<br>        gaus.SetMaximum(255);<br>        gaus.SetRadius(7);<br>        itkVectorD2 offset = new itkVectorD2(1.0);<br>        offset.SetElement(0, 0); // offset.SetElement(0, 2);<br>        offset.SetElement(1, 0); // offset.SetElement(1, 2);<br>        gaus.GetObjectToParentTransform().SetTranslation(offset);<br>        gaus.ComputeObjectToWorldTransform();<br><br>        itkSpatialObjectToImageFilterSO2IUC2 so2im = new <br>itkSpatialObjectToImageFilterSO2IUC2();<br>        so2im.SetInput(gaus);<br>        itkSize2 size = new itkSize2();<br>        size.SetElement(0, 15);<br>        size.SetElement(1, 25);<br>        so2im.SetSize(size);<br>        so2im.Update();<br><br><br>Julien Jomier wrote:<br>> Hi Ali,<br>><br>> Couple of things:<br>><br>> 1) Change the gaus.GetIndexToObjectTransform().SetTranslation(offset) to<br>> gaus.GetObjectToParentTransform().SetTranslation(offset)<br>><br>> 2) Add gaus.ComputeObjectToWorldTransform(); after setting the <br>> translation. This forces the recomputation of the world transform for <br>> the object.<br>><br>> 3) Don't forget to set the size of your image for the <br>> SpatialObjectToImageFilter using SetSize().<br>><br>> Here's the code I've been using (C++ version)<br>><br>>   typedef itk::GaussianSpatialObject<2> GSType;<br>>   GSType::Pointer gsp = GSType::New();<br>><br>>   gsp->SetMaximum(255);<br>>   gsp->SetRadius(7);<br>>   typedef itk::Vector<double,2> VectorType;<br>>   VectorType v;<br>>   v[0] = 10;<br>>   v[1] = 10;<br>>   gsp->GetObjectToParentTransform()->SetTranslation(v);<br>>   gsp->ComputeObjectToWorldTransform();<br>><br>>   typedef itk::Image<unsigned char,2> ImageType;<br>>   typedef itk::SpatialObjectToImageFilter<GType,ImageType> FilterType;<br>>   FilterType::Pointer filter = FilterType::New();<br>>   filter->SetInput(gsp);<br>>   FilterType::SizeType size;<br>>   size[0]=20;<br>>   size[1]=20;<br>>   filter->SetSize(size);<br>>   filter->Update();<br>><br>>   typedef itk::ImageFileWriter<ImageType> WriterType;<br>>   WriterType::Pointer writer= WriterType::New();<br>>   writer->SetFileName("test.jpg");<br>>   writer->SetInput(filter->GetOutput());<br>>   writer->Update();<br>><br>> Let me know if that works or not,<br>><br>> Julien<br>><br>> Ali - wrote:<br>>> Hi Julien,<br>>><br>>> It seems there is this bug in GaussianSpatialObject which causes to mess<br>>> up the whole spatial object image when the translation transform is<br>>> applied. Here is an example:<br>>><br>>> itkGaussianSpatialObject2 gaus = new itkGaussianSpatialObject2();<br>>> gaus.SetMaximum(255);<br>>> gaus.SetRadius(7);<br>>> itkVectorD2 offset = new itkVectorD2();<br>>> offset.SetElement(0, 0.0);<br>>> offset.SetElement(1, 0.0);<br>>> gaus.GetIndexToObjectTransform().SetTranslation(offset);<br>>><br>>> (The above code is in java, but can be used as a pseudo code). Notice<br>>> that whether the offset is zero or not, setting the translation value<br>>> messes up the gaussian object. Here are the results:<br>>><br>>> Without calling translation: http://i26.tinypic.com/2j4u7pd.jpg<br>>> With calling translation: http://i31.tinypic.com/iwrd5y.jpg<br>>><br>>> All I wanted to do was to have a gaussian object at the centre of the<br>>> image. Is there a better way of doing this?<br>>><br>>><br>>> -Ali<br>>><br>>><br>>><br>>><br>>> ------------------------------------------------------------------------<br>>> Miss your Messenger buddies when on-the-go? Get Messenger on your <br>>> Mobile! <http://clk.atdmt.com/UKM/go/msnnkmgl0010000001ukm/direct/01/><br>><br>><br><br><br><br /><hr />Get 5GB of online storage for free! <a href='http://clk.atdmt.com/UKM/go/msnnkmgl0010000005ukm/direct/01/' target='_new'>Get it Now! </a></body>
</html>