[Insight-users] Possible bug in GaussianSpatialObject

Ali - saveez at hotmail.com
Tue Jun 17 07:17:07 EDT 2008


Julien,

Unfortunately, your code still generates the same problem here. Even 
different values of SpatialObjectToImageFilter.SetSize() produces 
different pixel distributions. Here is an example:

SpatialObjectToImageFilter.SetSize(15, 15): 
http://i25.tinypic.com/5vnpmq_th.png
SpatialObjectToImageFilter.SetSize(15, 25): 
http://i31.tinypic.com/hvnfph_th.png

If things work smoothly in C++, it could be a problem with the 
development version of WrapITK, however, I do not get any warnings or 
exceptions with windows+java. Maybe Gaetan can confirm this problem with 
python and linux.


-Ali

Code:
        itkGaussianSpatialObject2 gaus = new itkGaussianSpatialObject2();
        gaus.SetMaximum(255);
        gaus.SetRadius(7);
        itkVectorD2 offset = new itkVectorD2(1.0);
        offset.SetElement(0, 0); // offset.SetElement(0, 2);
        offset.SetElement(1, 0); // offset.SetElement(1, 2);
        gaus.GetObjectToParentTransform().SetTranslation(offset);
        gaus.ComputeObjectToWorldTransform();

        itkSpatialObjectToImageFilterSO2IUC2 so2im = new 
itkSpatialObjectToImageFilterSO2IUC2();
        so2im.SetInput(gaus);
        itkSize2 size = new itkSize2();
        size.SetElement(0, 15);
        size.SetElement(1, 25);
        so2im.SetSize(size);
        so2im.Update();


Julien Jomier wrote:
> Hi Ali,
>
> Couple of things:
>
> 1) Change the gaus.GetIndexToObjectTransform().SetTranslation(offset) to
> gaus.GetObjectToParentTransform().SetTranslation(offset)
>
> 2) Add gaus.ComputeObjectToWorldTransform(); after setting the 
> translation. This forces the recomputation of the world transform for 
> the object.
>
> 3) Don't forget to set the size of your image for the 
> SpatialObjectToImageFilter using SetSize().
>
> Here's the code I've been using (C++ version)
>
>   typedef itk::GaussianSpatialObject GSType;
>   GSType::Pointer gsp = GSType::New();
>
>   gsp->SetMaximum(255);
>   gsp->SetRadius(7);
>   typedef itk::Vector VectorType;
>   VectorType v;
>   v[0] = 10;
>   v[1] = 10;
>   gsp->GetObjectToParentTransform()->SetTranslation(v);
>   gsp->ComputeObjectToWorldTransform();
>
>   typedef itk::Image ImageType;
>   typedef itk::SpatialObjectToImageFilter FilterType;
>   FilterType::Pointer filter = FilterType::New();
>   filter->SetInput(gsp);
>   FilterType::SizeType size;
>   size[0]=20;
>   size[1]=20;
>   filter->SetSize(size);
>   filter->Update();
>
>   typedef itk::ImageFileWriter WriterType;
>   WriterType::Pointer writer= WriterType::New();
>   writer->SetFileName("test.jpg");
>   writer->SetInput(filter->GetOutput());
>   writer->Update();
>
> Let me know if that works or not,
>
> Julien
>
> Ali - wrote:
>> Hi Julien,
>>
>> It seems there is this bug in GaussianSpatialObject which causes to mess
>> up the whole spatial object image when the translation transform is
>> applied. Here is an example:
>>
>> itkGaussianSpatialObject2 gaus = new itkGaussianSpatialObject2();
>> gaus.SetMaximum(255);
>> gaus.SetRadius(7);
>> itkVectorD2 offset = new itkVectorD2();
>> offset.SetElement(0, 0.0);
>> offset.SetElement(1, 0.0);
>> gaus.GetIndexToObjectTransform().SetTranslation(offset);
>>
>> (The above code is in java, but can be used as a pseudo code). Notice
>> that whether the offset is zero or not, setting the translation value
>> messes up the gaussian object. Here are the results:
>>
>> Without calling translation: http://i26.tinypic.com/2j4u7pd.jpg
>> With calling translation: http://i31.tinypic.com/iwrd5y.jpg
>>
>> All I wanted to do was to have a gaussian object at the centre of the
>> image. Is there a better way of doing this?
>>
>>
>> -Ali
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>> Miss your Messenger buddies when on-the-go? Get Messenger on your 
>> Mobile! 
>
>



_________________________________________________________________
Great deals on almost anything at eBay.co.uk. Search, bid, find and win on eBay today!
http://clk.atdmt.com/UKM/go/msnnkmgl0010000004ukm/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080617/4fab73b0/attachment.htm>


More information about the Insight-users mailing list