[Insight-users] Bug in CastImageFilter?
Luis Ibanez
luis.ibanez@kitware.com
Mon, 10 Feb 2003 08:09:05 -0500
Hi Mark,
Thanks for trying the direct writing.
You are right, It seems that the CastFilter
is not reinitializing the regions correctly.
This means that all the filters deriving
from the UnaryFunctor filter are affected
by the same RRD (Region Reinitialization
Disorder :-) )
We will look at this closely and keep you
updated.
BTW, thanks for sending the corrupted image,
it helps a lot to get an idea of what may
be going wrong with this filter.
Regards,
Luis
---------------------------------------
Mark Hastenteufel wrote:
> Hi Luis,
>
> if the problem would be in the image writer, then
> it should not work in both cases.
>
> I've tried to write out the image without
> casting (in float type) and it works.
>
> So the problem seems to be in the CastFilter.
>
> Mark
>
>
> PS: I've attached the output after the second
> call of SetInput() of the CatsImageFilter, i.e.,
> the image of the second pyramid level. Maybe
> it helps.
>
>
>
> Luis Ibanez schrieb:
>
>>Hi Mark,
>>
>>Thanks for reporting this.
>>
>>This is quite interesting since the CastImageFilter
>>is pretty simple. Most of its functionality is
>>actually implemented in its base class the
>>itkUnaryFunctorImageFilter which derives from
>>ImageToImageFilter, like:
>>
>> ImageToImageFilter
>> ^
>> |
>> |
>> UnaryFunctorImageFilter
>> ^
>> |
>> |
>> CastImageFilter
>>
>>The UnaryFunctorImagefilter implements all the
>>pixel-wise operation on the toolkit.
>>
>>The miss behaviour that you reported looks like
>>a problem in the negotiation of regions that
>>preceed the execution of the filter. It makes
>>suspect that the regions are negociated in the
>>first call, and not in the subsequent calls.
>>If this bug is there, it is affecting all the
>>other pixel-wise filter on the toolkit.
>>
>>However, there is also the possibility that
>>the problem is caused by the writer filter that
>>receives the output of the caster.
>>
>>Have you find during your trials any hint
>>indicating that the actual problem is produced
>>by the Caster and not the following writers ?
>>
>>For example, you could remove the caster from
>>the pipeline and use a float image type to
>>write in MetaImage format (which support
>>float pixel types). Then use the MetaImageViewer
>>application to verify the content of your output
>>images.
>>
>>This should help to eliminate one of the two
>>suspects here.
>>
>>Please let us know what you find,
>>
>> Thanks
>>
>> Luis
>>
>>----------------------------
>>
>>Mark Hastenteufel wrote:
>>
>>
>>>Hi!
>>>
>>>I've found a strange behaviour in itk::CastImageFilter. I've
>>>implemented a simple program which produces an image
>>>pyramid.
>>>The images on the respective level are written out to disk. The
>>>images are converted from float (internal type of PyramidFilter)
>>>to short using an ikt::CastImageFilter.
>>>
>>>
>>>Typedef's:
>>>
>>> typedef itk::Image<short,2> TInputImage2;
>>> typedef itk::Image<double,2> TOutputImage;
>>> typedef itk::MultiResolutionPyramidImageFilter< TOutputImage,
>>>TOutputImage > PyramidType;
>>> typedef itk::CastImageFilter< TOutputImage,TInputImage2 >
>>>CastFilterType;
>>>
>>>
>>>If using the following code:
>>>
>>>
>>> myPyramid->SetNumberOfLevels(noLevels);
>>> myPyramid->SetInput( image );
>>> myPyramid->UpdateLargestPossibleRegion();
>>>
>>> CastFilterType::Pointer myCaster = CastFilterType::New();
>>> for (int i=0 ; i<noLevels ; i++)
>>> {
>>> myCaster->SetInput( myPyramid->GetOutput(i) );
>>> myCaster->Update();
>>>
>>> char s[100];
>>> sprintf(s,"level%d.pic",i);
>>> Pic2itk::saveImage<TInputImage2>(s,myCaster->GetOutput());
>>> }
>>>
>>>
>>>just the image on the coarsest level is OK! The others are corrupted.
>>>This seems due to CastImageFilter. If declaring a cast-filter
>>>inside the for-loop, everything is OK!
>>>
>>> myPyramid->SetNumberOfLevels(noLevels);
>>> myPyramid->SetInput(myCaster2->GetOutput() );
>>> myPyramid->UpdateLargestPossibleRegion();
>>>
>>> for (int i=0 ; i<noLevels ; i++)
>>> {
>>> CastFilterType::Pointer myCaster = CastFilterType::New();
>>> myCaster->SetInput( myPyramid->GetOutput(i) );
>>> myCaster->Update();
>>>
>>> char s[100];
>>> sprintf(s,"level%d.pic",i);
>>> Pic2itk::saveImage<TInputImage2>(s,myCaster->GetOutput());
>>> }
>>>
>>>
>>>It seems, that the CastImageFilter doesn't work if SetInput is
>>>called more than one time. Is this a bug or did I made something
>>>wrong?
>>>
>>>
>>>Mark
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users@public.kitware.com
>>>http://public.kitware.com/mailman/listinfo/insight-users
>>>
>>>
>>
>
>
> ------------------------------------------------------------------------
>