[Insight-users] Possible bug in GaussianSpatialObject
Ali -
saveez at hotmail.com
Fri Jun 20 10:27:25 EDT 2008
Julien,
Sorry about the ambiguity, I used .bmp extension with vtkImageWriter, so
I guess vtkBMPWriter could produce the problem here on windows. Gaetan
has conformed the the problem happens for vtkJPEGWriter and vtkPNGWriter
as well on linux--this should be a separate problem.
I was trying to create a minimal pipeline which could demonstrate the
bug, unfortunately, whatever minimal example I tried so far demonstrated
any other bugs but the bug of interest. Since most of the bugs are
concentrated around the sticky ItkVtkGlue code, we'll focus on this for
now. Thank you for your help.
-Ali
Julien Jomier wrote:
> Ali,
>
> The vtkImageWriter is a superclass for the other file formats, I don't
> know what you want me to try.
>
> Julien
>
> Ali - wrote:
>> Julien,
>>
>> Thanks for trying this, the Update() of SpatialObjectToImageFilter
>> method is called was called during the test. Could you give it a try
>> with vtkImageWriter instead of vtkJPEGWriter The minimal pipeline could
>> produce the bug for Gaetan and I when it was ended with that filter.
>>
>>
>> -Ali
>>
>> Julien Jomier wrote:
>> > Ali,
>> >
>> > I just tried adding ItkVtk and having vtkJPEGWriter at the end of the
>> > pipeline and it works fine.
>> >
>> > Are you calling Update() explicitly on the
>> SpatialObjectToImageFilter?
>> > That might be the source of the problem.
>> >
>> > Julien
>> >
>> > Ali - wrote:
>> >> Julien,
>> >>
>> >> This seems to be one of those hard-to-detect bugs, now we know
>> that it
>> >> is very unlikely that wrapping causes the problem. This is a minimal
>> >> pipeline which can generate the bug:
>> >>
>> >> [itk::GaussianSpatialObject] -> [itk::SpatialObjectToImageFilter] ->
>> >> [itkImageToVTKImageFilter] -> [vtkWriter]
>> >>
>> >> The reason that you have never encountered this problem in ITK is
>> that
>> >> the pipelines normally end with an ITK writer. However, after
>> passing
>> >> the image buffer to a VTK writer, the output file is broken.
>> >>
>> >> One may argue that this is an ItkVtkGlue bug, but the fact that
>> we have
>> >> not observed anything similar in all other image filters suggests
>> that
>> >> there is something different in SpatialObjectToImageFilter. Is it
>> >> possible that some, possibly optional, step is not performed in
>> >> SpatialObjectToImageFilter? If you can try this with ItkVtkGlue,
>> it'd be
>> >> a big help to us.
>> >>
>> >>
>> >> -Ali
>> >>
>> >>
>> >> 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!
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >>
>> ------------------------------------------------------------------------
>> >> Messenger's gone Mobile! Get it now!
>> >>
>> >
>> >
>>
>>
>>
>> ------------------------------------------------------------------------
>> Miss your Messenger buddies when on-the-go? Get Messenger on your
>> Mobile!
>
>
_________________________________________________________________
http://clk.atdmt.com/UKM/go/msnnkmgl0010000009ukm/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080620/9ca39e94/attachment-0001.htm>
More information about the Insight-users
mailing list