[Insight-developers] X-ray flat field correction filter

Cory Quammen cquammen at cs.unc.edu
Mon Jan 16 21:41:08 EST 2012


[snip]
>  I've created a filter for applying the simple (S-D)/(F-D) correction
>  that we use for eliminating the effect of spatial variation in the
>  incoming beam intensity; I didn't find such a filter present already ;
>  but I simply copied TernaryAddImageFilter and changed the formula (and
>  the name). However I did this without understanding how it works; the
>  functor is defined in the header file but nowhere can I find where the
>  functor is actually set in the class that is derived from the parent
>  TernaryFunctorImageFilter class . (i.e. the call to SetFunctor(), where
>  is it?) I suppose this is done by some clever trick.

The TernaryFunctorImageFilter is templated over the functor type. The
functor is stored as a member variable of the class. It is defined as
an object, not a pointer to an object, so it exists as soon as you
create your version of the TernaryFunctorImageFilter. Hence, there is
no need to set it explicitly to get the filter to operate as you
expect.

>
>  It does, however, appear to work.
>
[snip]
>
>  Would it be useful to contribute these (albeit minor) modifications ,
>  I've called it TernaryFlatcorrImageFilter;  or is this already in the
>  library and I've missed it?

I'm pretty sure it is not in the library.

> If so I can begin putting a paper to the journal.

This is a good place for this contribution. If you have other ITK
classes useful for you specific application, you might consider
putting together an external module. See
http://www.itk.org/Wiki/ITK_Release_4/Modularization/Add_an_external_module_(external_module)
for details.

> Or is it too trivial to be worthwhile having a separate filter? But, the
> advanced c++ required to define a new functor, I can guarantee is a
> roadblock for some
>
>  (I suppose one could have used the parent class, defined a functor and
>  used SetFunctor, but actually copying TernaryAdd and modifying it
>  seemed easier!)

Defining a functor would almost certainly be the way to go rather than
copying the TernaryAdd filter. You could basically keep the functor
you have in your copy of the ternary add filter, throw away your
special version of the ternary functor filter, then instantiate the
usual TernaryFunctorImageFilter. It would look something like

namespace itk
{
namespace Functor
{
template< class TInput1, class TInput2, class TInput3, class TOutput >
class MySpecialFunctor {
 public:
   Add3() {}
  ~Add3() {}
  bool operator!=(const Add3 &) const
  {
    return false;
  }

  bool operator==(const Add3 & other) const
  {
    return !( *this != other );
  }

  inline TOutput operator()(const TInput1 & A,
                            const TInput2 & B,
                            const TInput3 & C) const
  { return (TOutput)( <insert equation here> ); }
};
}
}

typedef itk::Functor::MySpecialFunctor< PixelType1, PixelType2,
PixelType3, OutputPixelType > MyFunctorType;
typedef itk::TernaryFunctorImageFilter< InputImageType1,
InputImageType2, InputImageType3, OutputImageType, MyFunctorType >
MyTernaryFilterType;

MyTernaryFilterType::Pointer filter = MyTernaryFilterType::New();
// no need to set the functor type because one is already instantiated
when the filter is instantiated

Hope this helps,
Cory

>  Regards
>  Robert
>
>
>  54 /** \class TernaryFlatcorrImageFilter
>  55  * \brief Pixel-wise flat field correction using three images.
>  56  *
>  57  * Applying the formula I = (S-D) / (F-D))
>  58  * where input1 is S (signal i.e input image)
>  59  *       input2 is F (Flat or White Field Image)
>  60  *       input3 is D (Dark field image)
>  61  *       GetOutput() returns I (corrected Intensity)
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers



-- 
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill


More information about the Insight-developers mailing list