[Insight-users] Error :itk::MRIBiasFieldCorrectionFilter may be with src code

Luis Ibanez luis.ibanez@kitware.com
Mon, 28 Oct 2002 11:05:58 -0500


Hi Suresh,

You are right,

There is a minor problem with the MRIBiasFieldCorrector
header file.


I tried the following simple code:

#include "itkMRIBiasFieldCorrectionFilter.h"

int main()
{
   typedef unsigned char PixelType;
   typedef itk::Image< PixelType , 3 > ImageType;
   typedef itk::MRIBiasFieldCorrectionFilter<
            ImageType, ImageType, ImageType>  CorrectorFilterType;
   ImageType::Pointer image = ImageType::New();
   CorrectorFilterType::Pointer  corrector = CorrectorFilterType::New();
   corrector->SetInput( image );
   return 0;
}


and got the same error that you reported.


The reason as you pointed out is that the MRIBiasFieldCorrector
has an internal image type declared in line: 238
of file    Code/Algorithms/itkMRIBiasFieldCorrectionFilter.h

This is the input passed to the Energy function. However the
Energyfunction is templated over the first template argument
of the MRIBiasFiledCorrectionFilter, the TInputImage instead
of being templated over this internal image type.


In line 253 the declaration of EnergyFunctionType should be

   typedef MRIBiasEnergyFunction<
            InternalImageType,
            ImageMaskType,
            BiasFieldType > EnergyFunctionType;

instead of the current

   typedef MRIBiasEnergyFunction<
            TInputImage,
            ImageMaskType,
            BiasFieldType > EnergyFunctionType;


This has been fixed in the repository now.

Thanks for pointing this out.


Luis



===============================================




suresh wrote:
> Hi Luis,
> 
> Thanks for the quick response.
> But i dont see that the error was due to my Imagetype 's but the source 
> code of MRIBiasFieldCorrectionFilter.Let me give the full description of 
> my observation.
> 
> First: My source code for  your refernce.
> 
>     //
>     //    I have a template class which gives me the ITK image when 
> passed a pixel buffer     //    of any type.
>     //      this template class internally creates a ImageType with the 
> pixel type passed
>     typedef BufferToImageConversion<unsigned char> ConverterType;
>     typedef ConverterType::ImageType ImageType;
>     ConverterType converter;
>     ConverterType::ImagePointer imageMRI =  converter.GetImage(pMRI);
> 
>     typedef itk::MRIBiasFieldCorrectionFilter<ImageType, ImageType, 
> ImageType>            Corrector;
>     Corrector::Pointer filter = Corrector::New() ;
> 
>     filter->SetInput(imageMRI);    // SO THE IMAGE IS OF TYPE UNSIGNED 
> CHAR.
>     filter->IsBiasFieldMultiplicative(true) ;
>     filter->SetTissueClassStatistics(classMeans,classSigma) ;
>     filter->SetUsingInterSliceIntensityCorrection(true);
>     filter->SetSlicingDirection(2) ;
>     ProgressUpdate(35, "Apply filter ", MRIVolumeName);
>     filter->Update();
>     ImageType::Pointer imageMRIINHCOR = filter->GetOutput();
> 
> 
> Now My observations is...
>     As the compiler points the error as ...
> =>       m_EnergyFunction->SetImage(m_InternalInput) ;
> =>    itk\Algorithms\itkMRIBiasFieldCorrectionFilter.txx(233)
> 
>     the error could ber with the m_EnergyFunction or m_InternalInput.The 
> creation of these two is in the source is given as
> 
> //    typedef MRIBiasEnergyFunction<TInputImage, ImageMaskType, 
> BiasFieldType>
> //                                                         
> EnergyFunctionType;
> //    typedef typename EnergyFunctionType::Pointer            
> EnergyFunctionPointer;
> //    EnergyFunctionPointer  m_EnergyFunction ;
> //    typedef Image< float, itkGetStaticConstMacro(ImageDimension) > 
> InternalImageType ;
> //    InternalImagePointer m_InternalInput
> 
> 
> And i dont see any code related to casting the float image to unsigned 
> char image.
> Am i missing any thing here??
> Do i need to do plug-in any extrac code here??
> Please help me..
> 
> Thank you for your time and interest,
> 
> -suresh
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>