casa
$Rev:20696$
|
Class to compute sliding median. More...
#include <MedianSlider.h>
Public Member Functions | |
MedianSlider () | |
MedianSlider (int halfwin) | |
MedianSlider (const MedianSlider &other) | |
~MedianSlider () | |
MedianSlider & | operator= (const MedianSlider &other) |
void | cleanup () |
Float | add (Float d, Bool flag=False) |
Adds a datum to the slider. | |
Float | add () |
Adds a flagged datum. | |
Float | next (uInt n=1) |
Adds N flagged datums. | |
Float | add (const Vector< Float > &d, const Vector< Bool > &flag) |
Adds several datums at once (with corresponding flags) | |
Float | add (const Vector< Float > &d) |
Adds several non-flagged datums at once. | |
Int | nval () |
Returns the number of values currently in the window. | |
Float | median () |
Returns the current median value. | |
Float | prevVal (uInt n, Bool &flag) |
Returns a previous value (from n steps ago) from the sliding window. | |
Float | midpoint (Bool &flag) |
Returns value from midpoint (center) of window, possibly with flag. | |
Float | midpoint () |
Float | diff (Bool &flag) |
Returns the difference between the current median and the value at window center. | |
Float | diff () |
Bool | assure () |
For testing purposes only: verifies current value of median. | |
Static Public Member Functions | |
static size_t | objsize (int halfwin) |
returns total memory usage (in bytes) for a given halfwin size | |
Private Attributes | |
uInt | halfwin |
uInt | fullwin |
Float * | buf |
uInt * | index |
Bool * | valid |
uInt | ibuf |
uInt | nind |
Class to compute sliding median.
Public interface
MedianSlider is a class for efficient computing of sliding medians.
Flagging Agents make extended use of sliding medians.
Definition at line 62 of file MedianSlider.h.
Referenced by objsize().
casa::MedianSlider::MedianSlider | ( | int | halfwin | ) |
casa::MedianSlider::MedianSlider | ( | const MedianSlider & | other | ) |
Float casa::MedianSlider::add | ( | Float | d, |
Bool | flag = False |
||
) |
Adds a datum to the slider.
Once the window is full, newer values will push out older values. Returns the new median value. If flag is set to true, adds a "flagged" datum, one which takes up space in the window but is skipped during median computations.
Float casa::MedianSlider::add | ( | ) | [inline] |
Adds a flagged datum.
Definition at line 80 of file MedianSlider.h.
References add(), and casa::True.
Referenced by add().
Adds several datums at once (with corresponding flags)
Float casa::MedianSlider::add | ( | const Vector< Float > & | d | ) |
Adds several non-flagged datums at once.
For testing purposes only: verifies current value of median.
Throws an exception if it fails.
void casa::MedianSlider::cleanup | ( | ) |
Float casa::MedianSlider::diff | ( | Bool & | flag | ) | [inline] |
Returns the difference between the current median and the value at window center.
Optionally, also returns flag of median center
Definition at line 108 of file MedianSlider.h.
References median(), and midpoint().
Float casa::MedianSlider::diff | ( | ) | [inline] |
Float casa::MedianSlider::median | ( | ) | [inline] |
Float casa::MedianSlider::midpoint | ( | Bool & | flag | ) | [inline] |
Returns value from midpoint (center) of window, possibly with flag.
Definition at line 146 of file MedianSlider.h.
Float casa::MedianSlider::midpoint | ( | ) | [inline] |
Definition at line 103 of file MedianSlider.h.
References midpoint().
Referenced by diff(), and midpoint().
Float casa::MedianSlider::next | ( | uInt | n = 1 | ) |
Adds N flagged datums.
Int casa::MedianSlider::nval | ( | ) | [inline] |
Returns the number of values currently in the window.
This is less than the window width initially. Int size ();
Returns the number of non-flagged values in window
Definition at line 131 of file MedianSlider.h.
References nind.
static size_t casa::MedianSlider::objsize | ( | int | halfwin | ) | [inline, static] |
returns total memory usage (in bytes) for a given halfwin size
Definition at line 113 of file MedianSlider.h.
References MedianSlider().
MedianSlider& casa::MedianSlider::operator= | ( | const MedianSlider & | other | ) |
Float casa::MedianSlider::prevVal | ( | uInt | n, |
Bool & | flag | ||
) |
Returns a previous value (from n steps ago) from the sliding window.
Referenced by midpoint().
Float* casa::MedianSlider::buf [private] |
Definition at line 123 of file MedianSlider.h.
Referenced by median().
uInt casa::MedianSlider::fullwin [private] |
Definition at line 122 of file MedianSlider.h.
uInt casa::MedianSlider::halfwin [private] |
Definition at line 122 of file MedianSlider.h.
Referenced by midpoint().
uInt casa::MedianSlider::ibuf [private] |
Definition at line 126 of file MedianSlider.h.
uInt* casa::MedianSlider::index [private] |
Definition at line 124 of file MedianSlider.h.
Referenced by median().
uInt casa::MedianSlider::nind [private] |
Definition at line 126 of file MedianSlider.h.
Bool* casa::MedianSlider::valid [private] |
Definition at line 125 of file MedianSlider.h.