[Insight-users] itkBilateralImageFilter only works for Origin 0,0,0

Luis Ibanez luis.ibanez at kitware.com
Thu, 18 Mar 2004 10:39:11 -0500


Hi Jean-Michel,

Thanks for pointing this out,

... and for providing the fix  :-)


The issue has been logged as Bug # 686
http://www.itk.org/Bug/bug.php?op=show&bugid=686&pos=0


and your fix has been committed to the CVS repository.


Please let us know if you find further problems,


   Thanks



     Luis



-------------------------------------
jean-michel.rouet at philips.com wrote:

> I have the feeling that the itkBilateralImageFilter assumes that the input 
> origin is 0,0,0.
> 
> As a demo, I tried the following code (inspired from 
> itkBilateralImageFilterTest2.cxx):
> 
> #include "itkBilateralImageFilter.h"
> #include "itkMinimumMaximumImageCalculator.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> 
> int main(int argc, char* argv[] )
> {
>   typedef unsigned char PixelType;
>   const unsigned int Dimension = 3;
> 
>   typedef itk::Image<PixelType,Dimension> myImageType;
>   typedef itk::BilateralImageFilter<myImageType,myImageType> myFilterType;
> 
>   // read input
>   itk::ImageFileReader<myImageType>::Pointer
>       input = itk::ImageFileReader<myImageType>::New();
>       input->SetFileName(argv[1]);
>       input->Update();
>  
>   // Create the filter
>   myFilterType::Pointer filt = myFilterType::New();
>       filt->SetInput(input->GetOutput());
>       filt->SetDomainSigma( 4.0 );
>       filt->SetRangeSigma( 50.0 );
>       filt->SetFilterDimensionality( Dimension );
>       filt->Update();
>  
>   itk::MinimumMaximumImageCalculator<myImageType>::Pointer
>       minmax = itk::MinimumMaximumImageCalculator<myImageType>::New();
>   minmax->SetImage( filt->GetOutput() );
>   minmax->ComputeMinimum();
>   minmax->ComputeMaximum();
> 
>   int min = minmax->GetMinimum();
>   int max = minmax->GetMaximum();
>  
>   std::cout << "minimum = " << min << std::endl;
>   std::cout << "maximum = " << max << std::endl;
> 
>   // Generate test image
>   itk::ImageFileWriter<myImageType>::Pointer
>       writer = itk::ImageFileWriter<myImageType>::New();
>       writer->SetInput( filt->GetOutput() );
>       writer->SetFileName( "filtered.mhd" );
>       writer->Update();
>  
>   return 0;
> }
> 
> and as input I took the HeadrMRVolume.mhd from the Testing/Data/Input 
> directory.
> It works correctly (at least it outputs something!!! :-) )
> 
> Then I tried to modify the Origin of the input volume either by using 
> SetOrigin() on the input->GetOutput(), or by adding an Offset line in the 
> mhd header as 
> follows (origin set to -100 -200 -300) :
> 
> rouet at joebar /tmp>cat HeadMRVolume.mhd
> NDims = 3
> DimSize = 48 62 42
> Offset = -100 -200 -300
> ElementSize = 4.000000e+000 4.000000e+000 4.000000e+000
> ElementSpacing = 4.000000e+000 4.000000e+000 4.000000e+000
> ElementType = MET_UCHAR
> ElementByteOrderMSB = False
> ElementDataFile = HeadMRVolume.raw
> 
> then I ran again the test program, and it generated an empty image (filled 
> with 0), (maximum = minimum = 0)
> 
> I think this is not an expected result since the filter has no reason to 
> be origin dependant !
> Am I right ?
> 
> Regards,
> Jean-Michel
> 
> PS: 
> 
> I guess that the error comes from line 147 in itkBilateralImageFilter.txx 
> where the center of the gaussian should take into account the origin 
>     mean[i] = this->GetInput()->GetSpacing()[i]*radius[i]; // center pixel 
> pos
> should become
>     mean[i] = this->GetInput()->GetSpacing()[i]*radius[i] + 
> this->GetInput()->GetOrigin()[i]; // center pixel pos
> 
> Other solution could be to remove the line 141:
>           gaussianImage->SetOrigin( this->GetInput()->GetOrigin() );
> so that the gaussianImage kernel is independent of the origin.
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>