[Insight-users] Using KalmanLinearEstimator

Mathieu Malaterre mathieu.malaterre at gmail.com
Mon May 7 10:25:19 EDT 2007


Hello,

  I must be something obviously really wrong when using the
KalmanLinearEstimator class, because the results are way off. Could
someone please help find the obvious mistake I must have done.

thanks !
-Mathieu

Code is:

#include "itkKalmanLinearEstimator.h"
#include <iostream>

int main(int, char* [] )
{
  typedef itk::KalmanLinearEstimator<double,2> KalmanFilterType;

  typedef KalmanFilterType::VectorType    VectorType;
  typedef KalmanFilterType::MatrixType    MatrixType;
  typedef KalmanFilterType::ValueType     ValueType;

  KalmanFilterType filter;

  filter.ClearEstimation();
  filter.SetVariance(1.0);

  ValueType     measure;
  VectorType    predictor;

  // A ~ 0.323
  // B ~ 172.4
  const double points[][2] = {
    {-16.6817,167.095},
    {-44.4257,158.118},
    {-68.0884,150.462},
    {-87.7176,144.111},
    {-103.447,139.021},
    {-115.437,135.142},
  };
  const unsigned int N = sizeof(points) / ( 2 * sizeof( double ));

  predictor(1)  =  1.0;
  for(unsigned int ax=0; ax < N; ax++)
    {
    predictor(0) = points[ax][0];
    measure = points[ax][1];
    //std::cout << predictor(0) << "," << measure << std::endl;
    filter.UpdateWithNewMeasure(measure,predictor);
    }

  VectorType estimation = filter.GetEstimator();

  std::cout << std::endl << "The Estimation is : " << std::endl;
  std::cout << estimation;

  std::cout << std::endl << std::endl;
  return EXIT_SUCCESS;
}


On 5/6/07, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
> Hi Mathieu,
>
> You may want to try the KalmanLinearEstimator.
>
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1KalmanLinearEstimator.html
>
>
> Your estimator will be the vector [a,b],
>
> and your measures will be the vector [1,Y]
>
>
> The Kalman Linear Estimator should converge to the vector [a,b] that
> minimizes the sum of squared errors between X and (a+bY).
>
> For an example, you may want to look at:
>
>
>
>      Insight/Testing/Code/Algorithms/
>           itkKalmanLinearEstimatorTest.cxx
>
>
>
>     Regards,
>
>
>         Luis
>
>
> ---------------------------
> Mathieu Malaterre wrote:
> > Hello,
> >
> >  I have a pretty simple problem to solve and I was wondering if I
> > could reuse any brick already existing in ITK.
> >
> >  I am working with a 4D dataset (x,y,y and theta), where I can
> > express for each pixel that:
> >
> > I(x,y,z)/sin(theta) = F(x,y,z) + b*I(x,y,z)/tan(theta)
> >
> >  My goal here is to find out the b constant, I do not need the
> > F(x,y,z) part. Obvisouly all I need to do is draw the line
> >
> >   X = a + b Y
> >
> > where X = I(x,y,z)/sin(theta) and Y = I(x,y,z)/tan(theta) and the
> > slope will give me 'b'.
> >
> > Any suggestions on which class to reuse ?
> > thanks !
>


-- 
Mathieu
Tel: +33 6 32 13 33 40


More information about the Insight-users mailing list