[Insight-developers] SubtractImageFilter strange behavior ?
Gaetan Lehmann
gaetan.lehmann at jouy.inra.fr
Wed Nov 16 12:12:12 EST 2005
I haven't attached the image to the mail because it is rejected by the
list with it.
You can get it at http://voxel.jouy.inra.fr/gradient.png
On Wed, 16 Nov 2005 18:04:21 +0100, Gaetan Lehmann
<gaetan.lehmann at jouy.inra.fr> wrote:
>
> Hi,
>
> I have done a morphological gradient image filter in which I use a
> SubtractImageFilter. Everything seems to work fine, but
> when I tried to remove the subtract filter and do the subtraction by
> hand, I don't get the same result.
>
> This part of code:
>
> // Need to subtract the eroded image from the dialted one
> typename SubtractImageFilter<TInputImage, TInputImage,
> TOutputImage>::Pointer
> subtract=SubtractImageFilter<TInputImage,TInputImage,TOutputImage>::New();
> subtract->SetInput1( dilate->GetInput() );
> subtract->SetInput2( erode->GetOutput() );
>
> // graft our output to the subtract filter to force the proper regions
> // to be generated
> subtract->GraftOutput( this->GetOutput() );
>
> progress->RegisterInternalFilter(subtract,.1f);
>
> dilate->Update(); // needed to have the right progress values
> subtract->Update();
>
> // graft the output of the subtract filter back onto this filter's
> // output. this is needed to get the appropriate regions passed
> // back.
> this->GraftOutput( subtract->GetOutput() );
>
>
> and this one
>
> dilate->Update();
> erode->Update();
>
> const TInputImage* inputPtr1 = dilate->GetOutput();
> const TInputImage* inputPtr2 = erode->GetOutput();
> const TInputImage* inputPtr = this->GetInput();
> TOutputImage* outputPtr = this->GetOutput();
>
> ImageRegionConstIterator<TInputImage> inputIt1(inputPtr1,
> inputPtr->GetRequestedRegion());
> ImageRegionConstIterator<TInputImage> inputIt2(inputPtr2,
> inputPtr->GetRequestedRegion());
>
> ImageRegionIterator<TOutputImage> outputIt(outputPtr,
> inputPtr->GetRequestedRegion());
>
> inputIt1.GoToBegin();
> inputIt2.GoToBegin();
> outputIt.GoToBegin();
>
> while( !inputIt1.IsAtEnd() )
> {
> outputIt.Set( static_cast< typename TOutputImage::PixelType
> ( inputIt1.Get() - inputIt2.Get() ) );
> ++inputIt2;
> ++inputIt1;
> ++outputIt;
> }
>
>
> does not produce the same output.
>
> Am I doing something wrong ?
> Or is it a problem in SubtractImageFilter ?
>
> Attached gradient.png is the result with the subtract filter.
> http://voxel.jouy.inra.fr/darcs/contrib-itk/gradient/gradient.png is the
> result without the subtract filter.
> The full code is available at
> http://voxel.jouy.inra.fr/darcs/contrib-itk/gradient/
>
> Regards,
>
> Gaetan
>
--
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66 fax: 01 34 65 29 09
http://voxel.jouy.inra.fr
More information about the Insight-developers
mailing list