Public Member Functions | Public Attributes | Friends

ImageKalmanFilter Class Reference
[Auxilliary Tools]

Auxilliary Tool: A Collection of Kalman Filters for estimating the appearance of an image. More...

#include <ImageKalmanFilter.h>

List of all members.

Public Member Functions

ImageKalmanFilteroperator= (const ImageKalmanFilter &rhs)
 Assignment Operator. Perform a deep copy of another ImageKalmanFilter.
 ImageKalmanFilter (const ImageKalmanFilter &copy)
 Copy Constructor. Perform a deep copy of another ImageKalmanFilter.
 ImageKalmanFilter ()
 Default Constructor. Equivalent to calling the main constructor with an observation size of 340x240.
 ImageKalmanFilter (cv::Size obsSize)
 Main Constructor. Initialize with the size of the image that will be observed at each timestep.
virtual ~ImageKalmanFilter ()
 Destructor.
void setObsSize (cv::Size s)
 Tell the ImageKalmanFilter what size observations to expect. This allows you to change the underlying memory structrue of the ImageKalmanFilter without creating a new object.
cv::Size getObsSize ()
 Query the size of Observation that this ImageKalmanFilter expects.
void setWorldSizePadFactor (double val=7.0)
 Set the size of the ImageKalmanFilter in terms of the width and height of the observations.
void setUseRetinalCoordinates (int yesorno=1)
 Sets the coordinate frame to World Coordinates (0) or Retinal Coordinates (Non-0). By default, retinal coordinates are used.
void setMuPrior (double val=0.5)
 Set the mean of the Image intensity estimates to all be a specified value.
void setSigmaSquaredPrior (double val=0.25)
 Set the variance of the Image intensity estimates to all be a specified value.
void setRSquared (double std=0.0001)
 Set the pixel drift variance (how much do pixels change their value over time?).
void setQSquared (double std=0.01)
 Set the camera noise variance (how much do you trust an unreliable sensor?).
void setRSquared (IplImage **im)
 Set the pixel drift variance on a pixel-by-pixel basis. If you happen to know (or learn) that certain regions of the world have more motion than others, this is useful.
void setQSquared (IplImage **im)
 Set the sensor reliability on a pixel-by-pixel basis. If you happen to know (or learn) that certain regions of the lens have higher distortion than others, this may be useful.
int getUsesExternalREstimate () const
 Checks whether an external image of pixel-drifts has been supplied using setRSquared(IplImage**). If not (or if NULL was set), this returns 0, 1 otherwise.
int getUsesExternalQEstimate () const
 Checks whether an external image of sensor-noise has been supplied using setQSquared(IplImage**). If not (or if NULL was set), this returns 0, 1 otherwise.
int getNumTransformVals ()
 How large is the space of image transformations potentially induced by motor commands? Right now this is 2 (translation, x and y), but in the future the transform space may increase to include rotation, scale, etc., in which case this will return more.
void updateModel (IplImage *seenImage, const cv::Mat &tau, IplImage *sqDiffIm=NULL)
 Update the ImageKalmanFilter by adding a new seenImage at a specified transformation, tau. tau must be a vector of size [getNumTransformVals() x 1].
double obsLogLikelihood (const cv::Mat &tau, IplImage *seenImage)
 Compute the log-likelihood value of an observation given a particular transform (translation, x&y, in units of pixels).
likelihood modelLogLikelihood (const cv::Mat &tau, IplImage *seenImage)
 Compute the log-likelihood value of an observation given a particular transform (translation, x&y, in units of pixels).
likelihood modelLogLikelihoodFast (const cv::Mat &tau, IplImage *seenImage, double scale)
 Compute the approximate log-likelihood value of an observation given a particular transform (translation, x&y, in units of pixels).

Public Attributes

IplImage * mu
 The mean of the current pixel-wise estimate of the image intensity values. This is the actual underlying estimate data. It is exposed for convenient inspection. Don't modify it.
IplImage * Sigma
 The variance of the current pixel-wise estimate of the image intensity values. This is the actual underlying estimate data. It is exposed for convenient inspection. Don't modify it.

Friends

std::ostream & operator<< (std::ostream &ofs, const ImageKalmanFilter &feat)
 Write to a file.
std::istream & operator>> (std::istream &ifs, ImageKalmanFilter &feat)
 Read from a file.

Detailed Description

Auxilliary Tool: A Collection of Kalman Filters for estimating the appearance of an image.

The Kalman Filter gives a Mean estimate of the values of the image's pixels, and maintains a variance Sigma for each pixel.

Generally, only part of the image is seen at once. This region of the image will have its means updated, and its variances will shrink. All other regions will have their means held constant while their variances increase.

There are many parameters to a Kalman Filter that may be set:

It is useful to think of there being a stochastic relation between x, the true pixel value at a location, and y, the observed pixel value. Specifically y is drawn from a normal distribution with mean x and Variance Q.

It is also useful to think of there being a drift in x, i.e. the image pixel values may change over time. This drift is 0 mean, and has covariance R. If R is 0, you are making a strong assertion that the environment will never change, that nothing moves.

Finally, you may set a prior mean estimate Mu of x, and a prior uncertainty, Sigma.

Author:
Nicholas Butko
Date:
2010 version 0.4

Constructor & Destructor Documentation

ImageKalmanFilter::ImageKalmanFilter ( cv::Size  obsSize )

Main Constructor. Initialize with the size of the image that will be observed at each timestep.

This is the size of the camera input. By default, ImageKalmanFilter assumes that the total seeable world is less than 7 times the width and height of this image. For example, if the observation size that you get from your camera is 320x240, the size of the ImageKalmanFilter will be 2240x1680. You can change this after the constructor call by calling setWorldSizePadFactor to something other than 7.0.


Member Function Documentation

likelihood ImageKalmanFilter::modelLogLikelihood ( const cv::Mat &  tau,
IplImage *  seenImage 
)

Compute the log-likelihood value of an observation given a particular transform (translation, x&y, in units of pixels).

The gradients of the likelihood function with respect to tau are not currently computed.

likelihood ImageKalmanFilter::modelLogLikelihoodFast ( const cv::Mat &  tau,
IplImage *  seenImage,
double  scale 
)

Compute the approximate log-likelihood value of an observation given a particular transform (translation, x&y, in units of pixels).

This is done by a subsampling method, only sampling and comparing every [scale]th pixel of the current ImageKalmanFilter estimate (memory) with those of the seen image (sensation).

The gradients of the likelihood function with respect to tau are not currently computed.

void ImageKalmanFilter::setMuPrior ( double  val = 0.5 )

Set the mean of the Image intensity estimates to all be a specified value.

The default value of 0.5 reflects the assumption that pixel intensities are between 0 and 1. If your images uses a different range of (floating point) values, you may want to set a different mean.

void ImageKalmanFilter::setObsSize ( cv::Size  s )

Tell the ImageKalmanFilter what size observations to expect. This allows you to change the underlying memory structrue of the ImageKalmanFilter without creating a new object.

Note that this will essentially reconstruct the object, reallocating and reinitializing all data structure memory. The padSizeFactor (size of the world in relation to the observation size) will be used, so the total number of pixels in the ImageKalmanFilter will change.

void ImageKalmanFilter::setQSquared ( double  std = 0.01 )

Set the camera noise variance (how much do you trust an unreliable sensor?).

The default value of 0.01 reflects the assumption that pixel intensities are between 0 and 1. If your images uses a different range of (floating point) values, you may want to set a different mean. Note that 0.01 variance means standard deviation of 0.1. This is relatively high, and asserts that the current field of view is an unreliable representation of the world's appearance. This helps filter out abberations caused by rapid motion through the visual field.

void ImageKalmanFilter::setQSquared ( IplImage **  im )

Set the sensor reliability on a pixel-by-pixel basis. If you happen to know (or learn) that certain regions of the lens have higher distortion than others, this may be useful.

Learning the statistics of one's own sensor distortions is an active area of research, and this feature is not well supported.

You are responsible for managing the memory of the underlying image. Setting *im to NULL will cause the program to revert to uniform r-values across the image plane.

void ImageKalmanFilter::setRSquared ( double  std = 0.0001 )

Set the pixel drift variance (how much do pixels change their value over time?).

The default value of 0.0001 reflects the assumption that pixel intensities are between 0 and 1. If your images uses a different range of (floating point) values, you may want to set a different mean. Note that 0.0001 variance means standard deviation of 0.01. This is relatively low, and asserts that the appearance of the world will be mostly static.

void ImageKalmanFilter::setRSquared ( IplImage **  im )

Set the pixel drift variance on a pixel-by-pixel basis. If you happen to know (or learn) that certain regions of the world have more motion than others, this is useful.

Learning the statistics of motion in the world is an active area of research, and this feature is not well supported.

You are responsible for managing the memory of the underlying image. Setting *im to NULL will cause the program to revert to uniform r-values across the image plane.

void ImageKalmanFilter::setSigmaSquaredPrior ( double  val = 0.25 )

Set the variance of the Image intensity estimates to all be a specified value.

The default value of 0.25 reflects the assumption that pixel intensities are between 0 and 1. If your images uses a different range of (floating point) values, you may want to set a different mean. Note that 0.25 variance means standard deviation of 0.5.

void ImageKalmanFilter::setUseRetinalCoordinates ( int  yesorno = 1 )

Sets the coordinate frame to World Coordinates (0) or Retinal Coordinates (Non-0). By default, retinal coordinates are used.

In retinal coordinates, the center of the ImageKalmanFilter is always colocated with the center of the most recent observation. Actions are interpreted as being relevant to this central location.

In world coordinates, actions are interpreted as being relative to the servo reference frame rather than the camera reference frame.

The InternalMotionModel is much more robust in a retinal coordinate frame than in a servo coordinate frame. It is not recommended to set this to 0.

void ImageKalmanFilter::setWorldSizePadFactor ( double  val = 7.0 )

Set the size of the ImageKalmanFilter in terms of the width and height of the observations.

Note that this will essentially reconstruct the object, reallocating and reinitializing all data structure memory. The current obsSize (size of the images coming from a camera) will be used, so the total number of pixels in the ImageKalmanFilter will change.

void ImageKalmanFilter::updateModel ( IplImage *  seenImage,
const cv::Mat &  tau,
IplImage *  sqDiffIm = NULL 
)

Update the ImageKalmanFilter by adding a new seenImage at a specified transformation, tau. tau must be a vector of size [getNumTransformVals() x 1].

Optionally, this function can output the an image of the same size as seenImage representing the squared difference between what the ImageKalmanFilter expected to see based on the transform tau (memory) and what was actually seen (sensation). This may be useful in learning about the reliability of your sensors, and the spatial layout of systematic distortions.


The documentation for this class was generated from the following files: