w2kmeans::ImageMotionEstimator< GridType > Class Template Reference

Inheritance diagram for w2kmeans::ImageMotionEstimator< GridType >:

w2kmeans::MotionEstimator< GridType > w2kmeans::DefaultGridFilter w2kmeans::MotionEstimateSupplier< GridType > w2kmeans::MotionEstimateHandler< GridType > w2img::SingleData2DFilter w2img::Data2DFilter w2kmeans::HSMotionEstimator< GridType > w2kmeans::KLTMotionEstimator< GridType > List of all members.

Detailed Description

template<class GridType>
class w2kmeans::ImageMotionEstimator< GridType >

Estimates motion using a constant sized neighborhood template at all valid pixels in the given image and using the minimum mean absolute error.

Author:
Lakshman
Version:
Id
w2kmeans_ImageMotionEstimator.h,v 1.10 2009/09/11 21:01:41 lakshman Exp


Public Member Functions

 ImageMotionEstimator (size_t maxVelocityInMetersPerSecond=20, size_t templateRadiusInKilometers=3)
void setMinimumThreshold (double newThresh)
 changes the minimum threshold from the default of 20
void setGoodnessFraction (double newFrac)
 What fraction of the pixels in the neigborhood have to be valid before motion estimation is done at that pixel? By default, this is 0.5.
virtual bool computeMotionEstimate (const GridType &oldImage, const GridType &newImage, int maxMotion_x, int maxMotion_y, const ScaleCalculator< GridType > &)
 Computes the pixel movement that if present in the oldImage would have made that image most similar to this one.
virtual ~ImageMotionEstimator ()
void setModelWindField (code::SmartPtr< code::WindFieldStruct< GridType > > wf)
 Set background (model) estimate.
code::SmartPtr< code::WindFieldStruct<
GridType > > 
remap (const code::WindFieldStruct< GridType > &orig)
void handleMotionEstimate (const GridType &east, const GridType &south, const GridType &rateOfIncrease, size_t scale, bool complete)
 We will use the result from scale = myScale -1 as the seed for this one.
void setMinimumTimeBetweenFrames (int newMinimumTimeDiffInSeconds)
 Specify the minimum time that should have elapsed between frames for them to be used in motion computation.
void setMinimumTimeBetweenEstimates (int newMinimumTimeDiffInSeconds)
 Specify the minimum time that should have elapsed between motion estimates.
virtual std::vector< code::SmartPtr<
code::DataType > > 
getIntermediateOutputs (const GridType &currData, const GridType &ux, const GridType &uy) const
virtual bool shouldProcessInputAt (const code::Time &newTime) const
 are we ready to process the next input or are we waiting .
virtual void initResults (const GridType &newdata)
 the base-class method initializes the xmovement, ymovement and growth rate to missing/zero.
void setQuantizationLevel (double newLevel)
 Set the motion vectors to be quantized to this level.
void setPostprocessingFilter (code::SmartPtr< w2img::ImageFilter > newFilter)
 Add a postprocessing filter on the motion estimates.
template<class X>
code::SmartPtr< code::DataType > computeMotion (const w2img::GeographicData2DAdapter< X > &data)
 implemented for several code 2D data types.
code::SmartPtr< code::DataType > filter (const GridType &)
code::SmartPtr< code::DataType > filter (const code::LatLonGrid &)
code::SmartPtr< code::DataType > filter (const code::RadialSet &)
code::SmartPtr< code::DataType > filter (const code::CartesianGrid2D &)
void process (code::PolarGrid &)
 Note that you need to call getResult() to get the result.
void process (code::RadialSet &)
 Note that you need to call getResult() to get the result.
void process (code::CartesianGrid2D &)
 Note that you need to call getResult() to get the result.
void process (code::LatLonGrid &)
 Note that you need to call getResult() to get the result.
void process (code::WindFieldStruct< code::LatLonGrid > &)
 Note that you need to call getResult() to get the result.
void process (code::WindFieldStruct< code::CartesianGrid2D > &)
 Note that you need to call getResult() to get the result.
void allowChangingMissingData (bool in)
 Should we filter at missing data values also, or not process missing values? By default, smoothing around a missing value might produce a value at that point in the result i.e.
bool canChangeMissing () const
void setToHandleRadialData (bool in)
 Pass in true if radial data should be filtered directly instead, of as is default, to convert to CartesianGrid before contouring.
void setCartesianGridResolutionRatio (double inres)
 changes the grid resolution of CartesianGrids created from RadialSets from that of the gate width.
void setCartesianGridDimension (const code::Length &indim)
 clips cartesian grids to this extent in the horizontal and vertical directions.
void setWrapAroundRadials (size_t numWrapAroundRadials)
 Normally, the RadialSet processing is done with no radial "wrapping".
size_t getWrapAroundRadials () const
code::SmartPtr< code::DataType > getResult ()
 get the result of the filtering -- returns 0 on error.
void reset ()
void addMotionEstimateHandler (code::SmartPtr< MotionEstimateHandler< GridType > > a)
 Add an estimate handler.
bool isProcessing () const
 returns true while processing the input, and false if waiting for new inputs.
virtual void handleIntermediateProduct (const code::DataType &prod)

Protected Member Functions

virtual code::SmartPtr< code::DataType > computeMotionFromGrids (const GridType &oldData, const GridType &newData)
virtual void preprocessInputData (GridType &image)
 thresholds and sets all values below minThresh to be missing.
virtual code::SmartPtr< code::DataType > computeMotionFromGrid (const GridType &oldData)
virtual void ageOff ()
 called after the motion estimating is done.
bool estimateBestMovement (const code::Image< float > &error_field, size_t num_pixels_in_mask, double *x, double *y)
 Fills in the row and column corresponding to the minimization of the error field.
virtual void fillMissingMovement (GridType &x, GridType &y, GridType &gr, const ScaleCalculator< GridType > &)
 The default behavior is to fill the missing movement with the global mean.
const code::Time & getPreviousComputationTime () const
int getTimeBetweenFrames () const
 in seconds.
bool hasModelWindField () const
const GridType & getModel_U () const
const GridType & getModel_V () const
void notifyMotionEstimate (const GridType &motionEast, const GridType &motionSouth, const GridType &growthRate, size_t scale, bool complete)
 subclass implementors should call this method when they have this information.
void notifyIntermediateProduct (const code::DataType &grid)
 this method may be called for handlers who write out intermediate products.
void setProcessingFlag (bool input)

Protected Attributes

const double templateRadius
double minThresh
double goodnessThreshold
int halfSize_x
int halfSize_y
GridType myXmovement
 result of computeMotionEstimate.
GridType myYmovement
 result of computeMotionEstimate.
GridType myRateOfIncrease
 result of computeMotionEstimate.
size_t myScale
code::SmartPtr< code::DataType > myResult


Constructor & Destructor Documentation

template<class GridType>
w2kmeans::ImageMotionEstimator< GridType >::ImageMotionEstimator ( size_t  maxVelocityInMetersPerSecond = 20,
size_t  templateRadiusInKilometers = 3 
)

template<class GridType>
virtual w2kmeans::ImageMotionEstimator< GridType >::~ImageMotionEstimator (  )  [virtual]


Member Function Documentation

template<class GridType>
void w2kmeans::MotionEstimateSupplier< GridType >::addMotionEstimateHandler ( code::SmartPtr< MotionEstimateHandler< GridType > >  a  )  [inline, inherited]

Add an estimate handler.

we will call handleMotionEstimate on this object whenever we generate a new motion estimate.

template<class GridType>
virtual void w2kmeans::MotionEstimator< GridType >::ageOff (  )  [protected, virtual, inherited]

called after the motion estimating is done.

the new data is oldData.back() at this point.

void w2img::SingleData2DFilter::allowChangingMissingData ( bool  in  )  [inline, virtual, inherited]

Should we filter at missing data values also, or not process missing values? By default, smoothing around a missing value might produce a value at that point in the result i.e.

the bool is true.

Implements w2img::Data2DFilter.

bool w2img::SingleData2DFilter::canChangeMissing (  )  const [inline, virtual, inherited]

Implements w2img::Data2DFilter.

template<class GridType>
template<class X>
code::SmartPtr<code::DataType> w2kmeans::MotionEstimator< GridType >::computeMotion ( const w2img::GeographicData2DAdapter< X > &  data  )  [inherited]

implemented for several code 2D data types.

template<class GridType>
virtual bool w2kmeans::ImageMotionEstimator< GridType >::computeMotionEstimate ( const GridType &  oldImage,
const GridType &  newImage,
int  maxMotion_x,
int  maxMotion_y,
const ScaleCalculator< GridType > &   
) [virtual]

Computes the pixel movement that if present in the oldImage would have made that image most similar to this one.

Parameters:
maxMotion -- how many pixels we are allowed to move the local template in order to get a match.
halfSize -- half size of the local template used to compute the match.
Note: the old and new images should be the same size.

Returns:
false if the movement could not be computed.
Subclasses will fill in myXMovement, myYMovement and myIncreaseRate images. These images will be initialized to the right size by the MotionEstimator method. Movement values will be init-ed to MISSING and increase rate to 0.

Implements w2kmeans::MotionEstimator< GridType >.

Reimplemented in w2kmeans::HSMotionEstimator< GridType >, and w2kmeans::KLTMotionEstimator< GridType >.

template<class GridType>
virtual code::SmartPtr<code::DataType> w2kmeans::MotionEstimator< GridType >::computeMotionFromGrid ( const GridType &  oldData  )  [protected, virtual, inherited]

template<class GridType>
virtual code::SmartPtr<code::DataType> w2kmeans::ImageMotionEstimator< GridType >::computeMotionFromGrids ( const GridType &  oldData,
const GridType &  newData 
) [protected, virtual]

Reimplemented from w2kmeans::MotionEstimator< GridType >.

template<class GridType>
bool w2kmeans::MotionEstimator< GridType >::estimateBestMovement ( const code::Image< float > &  error_field,
size_t  num_pixels_in_mask,
double *  x,
double *  y 
) [protected, inherited]

Fills in the row and column corresponding to the minimization of the error field.

Returns:
false if the quality of the error field was too poor to obtain a satisfactory minimum.

template<class GridType>
virtual void w2kmeans::MotionEstimator< GridType >::fillMissingMovement ( GridType &  x,
GridType &  y,
GridType &  gr,
const ScaleCalculator< GridType > &   
) [protected, virtual, inherited]

The default behavior is to fill the missing movement with the global mean.

The global mean is in m/s. The scale calculator is provided incase subclasses need to compute m/s from pixels/frame

Reimplemented in w2kmeans::SegmentMotionEstimator< GridType >.

code::SmartPtr<code::DataType> w2kmeans::DefaultGridFilter::filter ( const code::CartesianGrid2D &   )  [virtual, inherited]

Implements w2img::SingleData2DFilter.

code::SmartPtr<code::DataType> w2kmeans::DefaultGridFilter::filter ( const code::RadialSet &   )  [virtual, inherited]

Implements w2img::SingleData2DFilter.

code::SmartPtr<code::DataType> w2kmeans::DefaultGridFilter::filter ( const code::LatLonGrid &   )  [virtual, inherited]

Implements w2img::SingleData2DFilter.

template<class GridType>
code::SmartPtr<code::DataType> w2kmeans::MotionEstimator< GridType >::filter ( const GridType &   )  [inherited]

template<class GridType>
virtual std::vector< code::SmartPtr<code::DataType> > w2kmeans::MotionEstimator< GridType >::getIntermediateOutputs ( const GridType &  currData,
const GridType &  ux,
const GridType &  uy 
) const [inline, virtual, inherited]

Reimplemented in w2kmeans::SegmentMotionEstimator< GridType >.

template<class GridType>
const GridType& w2kmeans::MotionEstimator< GridType >::getModel_U (  )  const [inline, protected, inherited]

template<class GridType>
const GridType& w2kmeans::MotionEstimator< GridType >::getModel_V (  )  const [inline, protected, inherited]

template<class GridType>
const code::Time& w2kmeans::MotionEstimator< GridType >::getPreviousComputationTime (  )  const [inline, protected, inherited]

code::SmartPtr<code::DataType> w2img::Data2DFilter::getResult (  )  [inline, inherited]

get the result of the filtering -- returns 0 on error.

This may or may not be the same data as passed in, for example process(RadialSet) may return a CartesianGrid.

template<class GridType>
int w2kmeans::MotionEstimator< GridType >::getTimeBetweenFrames (  )  const [inline, protected, inherited]

in seconds.

size_t w2img::SingleData2DFilter::getWrapAroundRadials (  )  const [inline, virtual, inherited]

Implements w2img::Data2DFilter.

template<class GridType>
virtual void w2kmeans::MotionEstimateHandler< GridType >::handleIntermediateProduct ( const code::DataType &  prod  )  [virtual, inherited]

template<class GridType>
void w2kmeans::MotionEstimator< GridType >::handleMotionEstimate ( const GridType &  east,
const GridType &  south,
const GridType &  rateOfIncrease,
size_t  scale,
bool  complete 
) [virtual, inherited]

We will use the result from scale = myScale -1 as the seed for this one.

(If we are not attached, a MISSING_DATA will be used).

Implements w2kmeans::MotionEstimateHandler< GridType >.

template<class GridType>
bool w2kmeans::MotionEstimator< GridType >::hasModelWindField (  )  const [inline, protected, inherited]

template<class GridType>
virtual void w2kmeans::MotionEstimator< GridType >::initResults ( const GridType &  newdata  )  [virtual, inherited]

the base-class method initializes the xmovement, ymovement and growth rate to missing/zero.

Reimplemented in w2kmeans::SegmentMotionEstimator< GridType >.

template<class GridType>
bool w2kmeans::MotionEstimateSupplier< GridType >::isProcessing (  )  const [inline, inherited]

returns true while processing the input, and false if waiting for new inputs.

template<class GridType>
void w2kmeans::MotionEstimateSupplier< GridType >::notifyIntermediateProduct ( const code::DataType &  grid  )  [protected, inherited]

this method may be called for handlers who write out intermediate products.

template<class GridType>
void w2kmeans::MotionEstimateSupplier< GridType >::notifyMotionEstimate ( const GridType &  motionEast,
const GridType &  motionSouth,
const GridType &  growthRate,
size_t  scale,
bool  complete 
) [protected, inherited]

subclass implementors should call this method when they have this information.

template<class GridType>
virtual void w2kmeans::ImageMotionEstimator< GridType >::preprocessInputData ( GridType &  image  )  [protected, virtual]

thresholds and sets all values below minThresh to be missing.

Reimplemented from w2kmeans::MotionEstimator< GridType >.

void w2img::SingleData2DFilter::process ( code::WindFieldStruct< code::CartesianGrid2D > &   )  [inherited]

Note that you need to call getResult() to get the result.

The input data is not changed.

void w2img::SingleData2DFilter::process ( code::WindFieldStruct< code::LatLonGrid > &   )  [inherited]

Note that you need to call getResult() to get the result.

The input data is not changed.

void w2img::SingleData2DFilter::process ( code::LatLonGrid &   )  [inherited]

Note that you need to call getResult() to get the result.

The input data is not changed.

void w2img::SingleData2DFilter::process ( code::CartesianGrid2D &   )  [inherited]

Note that you need to call getResult() to get the result.

The input data is not changed.

void w2img::SingleData2DFilter::process ( code::RadialSet &   )  [inherited]

Note that you need to call getResult() to get the result.

The input data is not changed.

void w2img::SingleData2DFilter::process ( code::PolarGrid &   )  [inherited]

Note that you need to call getResult() to get the result.

The input data is not changed.

template<class GridType>
code::SmartPtr<code::WindFieldStruct<GridType> > w2kmeans::MotionEstimator< GridType >::remap ( const code::WindFieldStruct< GridType > &  orig  )  [inherited]

void w2img::Data2DFilter::reset (  )  [inline, inherited]

void w2img::SingleData2DFilter::setCartesianGridDimension ( const code::Length &  indim  )  [inline, virtual, inherited]

clips cartesian grids to this extent in the horizontal and vertical directions.

(Removes the boundaries, keeping the image centered at the same spot).

by default, no such clipping is done. Pass in Length() to turn off clipping.

Implements w2img::Data2DFilter.

void w2img::SingleData2DFilter::setCartesianGridResolutionRatio ( double  inres  )  [inline, virtual, inherited]

changes the grid resolution of CartesianGrids created from RadialSets from that of the gate width.

For example, if the RadialSet's gate width is 1km, then if the ratio is 3, the CartesianGrid's resolution is 0.33km. If the input ratio is 0.33 then the grid resolution will be 3km.

Implements w2img::Data2DFilter.

template<class GridType>
void w2kmeans::ImageMotionEstimator< GridType >::setGoodnessFraction ( double  newFrac  )  [inline]

What fraction of the pixels in the neigborhood have to be valid before motion estimation is done at that pixel? By default, this is 0.5.

template<class GridType>
void w2kmeans::ImageMotionEstimator< GridType >::setMinimumThreshold ( double  newThresh  )  [inline]

changes the minimum threshold from the default of 20

template<class GridType>
void w2kmeans::MotionEstimator< GridType >::setMinimumTimeBetweenEstimates ( int  newMinimumTimeDiffInSeconds  )  [inherited]

Specify the minimum time that should have elapsed between motion estimates.

The default is -1, i.e. always do computations.

template<class GridType>
void w2kmeans::MotionEstimator< GridType >::setMinimumTimeBetweenFrames ( int  newMinimumTimeDiffInSeconds  )  [inherited]

Specify the minimum time that should have elapsed between frames for them to be used in motion computation.

a non-positive value indicates that successive frames should be used regardless of the time difference.

template<class GridType>
void w2kmeans::MotionEstimator< GridType >::setModelWindField ( code::SmartPtr< code::WindFieldStruct< GridType > >  wf  )  [inline, inherited]

Set background (model) estimate.

This background field should have been remapped to fit the dimensions of the tracked product.

See also:
remap

template<class GridType>
void w2kmeans::MotionEstimator< GridType >::setPostprocessingFilter ( code::SmartPtr< w2img::ImageFilter newFilter  )  [inline, inherited]

Add a postprocessing filter on the motion estimates.

by default, there is no postprocessing done on these.

template<class GridType>
void w2kmeans::MotionEstimateSupplier< GridType >::setProcessingFlag ( bool  input  )  [inline, protected, inherited]

template<class GridType>
void w2kmeans::MotionEstimator< GridType >::setQuantizationLevel ( double  newLevel  )  [inline, inherited]

Set the motion vectors to be quantized to this level.

For example, if newLevel = 5, the resulting estimates will be one of 0, 5, 10, etc. If newLevel is -ve, quantization is turned off.

the default is set for no quantization.

void w2img::SingleData2DFilter::setToHandleRadialData ( bool  in  )  [inline, virtual, inherited]

Pass in true if radial data should be filtered directly instead, of as is default, to convert to CartesianGrid before contouring.

Implements w2img::Data2DFilter.

void w2img::SingleData2DFilter::setWrapAroundRadials ( size_t  numWrapAroundRadials  )  [inline, virtual, inherited]

Normally, the RadialSet processing is done with no radial "wrapping".

You can remove boundary effects in the azimuthal direction by calling this function with a value greater than zero.

When filtering with a 5x5 kernel, this class will automatically add 5 radials, do the filtering and then remove the extra five radials. In that case, the number of wraparound radials should be set to 5.

Implements w2img::Data2DFilter.

template<class GridType>
virtual bool w2kmeans::MotionEstimator< GridType >::shouldProcessInputAt ( const code::Time &  newTime  )  const [virtual, inherited]

are we ready to process the next input or are we waiting .

..

Reimplemented from w2kmeans::MotionEstimateSupplier< GridType >.


Member Data Documentation

template<class GridType>
double w2kmeans::ImageMotionEstimator< GridType >::goodnessThreshold [protected]

template<class GridType>
int w2kmeans::ImageMotionEstimator< GridType >::halfSize_x [mutable, protected]

template<class GridType>
int w2kmeans::ImageMotionEstimator< GridType >::halfSize_y [mutable, protected]

template<class GridType>
double w2kmeans::ImageMotionEstimator< GridType >::minThresh [protected]

template<class GridType>
GridType w2kmeans::MotionEstimator< GridType >::myRateOfIncrease [protected, inherited]

result of computeMotionEstimate.

code::SmartPtr<code::DataType> w2img::Data2DFilter::myResult [protected, inherited]

template<class GridType>
size_t w2kmeans::MotionEstimator< GridType >::myScale [protected, inherited]

template<class GridType>
GridType w2kmeans::MotionEstimator< GridType >::myXmovement [protected, inherited]

result of computeMotionEstimate.

template<class GridType>
GridType w2kmeans::MotionEstimator< GridType >::myYmovement [protected, inherited]

result of computeMotionEstimate.

template<class GridType>
const double w2kmeans::ImageMotionEstimator< GridType >::templateRadius [protected]


Generated on Fri May 4 13:40:24 2012 for WDSS-IIw2algs by  doxygen 1.4.7