USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::QuickFilter Class Reference

Container for boxcar statistics. More...

#include <QuickFilter.h>

Collaboration diagram for Isis::QuickFilter:
Collaboration graph

Public Member Functions

 QuickFilter (const int ns, const int width, const int height)
 Constructs a QuickFilter object with accumulators and counters set to zero.
 
 ~QuickFilter ()
 Destroys the QuickFilter object.
 
double Average (const int index)
 Computes and returns the boxcar average at pixel index (zero based).
 
double Variance (const int index)
 Computes and returns the boxcar variance at pixel index (zero based).
 
int Count (const int index)
 Computes and returns the number of valid pixels in the boxcar at pixel index (zero based).
 
int Width () const
 Returns the width of the boxcar.
 
int HalfWidth () const
 Returns the half the width of the boxcar rounded down because the boxcar size is odd.
 
int Height () const
 Returns the height of the boxcar.
 
int HalfHeight () const
 Returns the half the height of the boxcar rounded down because the boxcar size is odd.
 
int Samples () const
 Returns the number of samples in a line.
 
double Low () const
 Returns the lowest pixel value included in filtering computations.
 
double High () const
 Returns the highest pixel value included in filtering computations.
 
int MinimumPixels () const
 Returns the minimum number of pixels which need to be valid inside the boxcar.
 
void AddLine (const double *buf)
 Add an array of doubles to the accumulators and counters.
 
void RemoveLine (const double *buf)
 Remove an array of doubles from the accumulators and counters.
 
void Reset ()
 Reset all accumulators and counters to zero.
 
void SetMinMax (const double minimum, const double maximum)
 This method is used to set the minimum/maximum valid values.
 
void SetMinimumPixels (const int minimumValid)
 This method is used to set the minimum number of valid pixels in the boxcar.
 

Private Member Functions

void Compute (const int index)
 Computes the moving boxcar sums and counts for the Average, Variance, and count methods.
 

Private Attributes

double * p_sums
 Sum accumulator for each column/sample.
 
double * p_sumsqrs
 
This is identical to p_sums with the exception

that the pixel values are squared before summing occurs.

 
int * p_counts
 
    This is identical to p_sums with the exception

that it keeps count of the number of valid pixels in p_sums and p_sumsqrs.

 
int p_ns
 This value is initialized in the constructor.
 
double p_minimum
 Minimum valid pixel value.
 
double p_maximum
 Maximum valid pixel value.
 
int p_minimumPixels
 
 The minimum number of pixels in the boxcar which

must be valid (not special and inside p_minimum/p_maximum) in order for Average and Variance to compute a value.

 
int p_width
 This is the width of the boxcar.
 
int p_halfWidth
 
     This is half the width of the boxcar rounded

down to the next integer since the boxcar is always odd.

 
int p_height
 This is the height of the boxcar.
 
int p_halfHeight
 
    This is half the height of the boxcar rounded

down to the next integer since the boxcar is always odd.

 
double p_lastSum
 The last sum of a full boxcar.
 
double p_lastSumsqr
 See p_lastSum.
 
int p_lastCount
 See p_lastSum.
 
int p_lastIndex
 
      This is used to keep track of the last index

passed into the Average, Variance and/or count method.

 
int p_linesAdded
 
     This is used to keep track of the number of

lines added.

 

Detailed Description

Container for boxcar statistics.

This class is used to compute statisics for NxM boxcars, where N and M are positive odd integers. In general, this object will be loaded by another derived class such as FilterLoader or FilterProcess. The programmer can then use the methods in this class to compute statistics such as the boxcar average, variance, and number of valid pixels in the boxcar.

If you would like to see QuickFilter being used in implementation, see FilterLoader or FilterProcess

Author
2002-06-20 Jeff Anderson
History:

2002-07-10 Jeff Anderson - Added the Compute private method and made it unfold data at the edges as opposed to using NULL values.

2002-07-15 Jeff Anderson - Added Low and High methods

2002-08-01 Jeff Anderson - Added MinimumPixels method

2003-02-14 Jeff Anderson - Changed unfolding technique to use symmetry as opposed to mirroring (i.e., 32123 not 21123)

2003-05-16 Stuart Sides - Modified schema from astrogeology... isis.astrogeology...

2003-08-27 Jeff Anderson - Modified variance method to divide by (n-1)*n instead of n*n

2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen documentation

Todo:

2005-02-15 Jeff Anderson - add coded example to class documentation

2005-05-23 Jeff Anderson - Unlikely but we may have issues with 2GB+ cubes. It's unlikely because the boxcar size would have to have more than 2^32-1 pixels.

Definition at line 66 of file QuickFilter.h.

Constructor & Destructor Documentation

Isis::QuickFilter::QuickFilter ( const int  ns,
const int  width,
const int  height 
)

Constructs a QuickFilter object with accumulators and counters set to zero.

Because this is a line based filtering object, the number of samples and the boxcar size must be given to the constructor.

Parameters
nsNumber of samples in the cube
widthWidth of the boxcar (must be odd)
heightHeight of the boxcar (must be odd)
Exceptions
Isis::IException::Programmer

Definition at line 43 of file QuickFilter.cpp.

References _FILEINFO_.

Isis::QuickFilter::~QuickFilter ( )

Destroys the QuickFilter object.

Definition at line 113 of file QuickFilter.cpp.

Member Function Documentation

void Isis::QuickFilter::AddLine ( const double *  buf)

Add an array of doubles to the accumulators and counters.

This method must be invoked enough times to satisfy the height requirements of the boxcar. Note, however this is not strictly enforced. The method will check to make sure you have not added beyond the height of the boxcar. Therefore, you must remove a line before adding a new one.

Parameters
bufArray of doubles to add
Exceptions
Isis::iException::Programmer

Definition at line 178 of file QuickFilter.cpp.

References _FILEINFO_, and Isis::IsValidPixel().

Referenced by Isis::ProcessByQuickFilter::StartProcess().

double Isis::QuickFilter::Average ( const int  index)

Computes and returns the boxcar average at pixel index (zero based).

No error checks are done for out of array bounds conditions. If there are not enough valid pixels in the boxcar then Isis::NULL8 is returned. The routine works the fastest when sequentially accessing the averages (e.g., index = 0,1,2,...).

Parameters
indexZero based sample position
Returns
double

Definition at line 229 of file QuickFilter.cpp.

void Isis::QuickFilter::Compute ( const int  index)
private

Computes the moving boxcar sums and counts for the Average, Variance, and count methods.

No error checks are done for out of array bounds conditions. The routine works the fastest when sequentially accessing the averages (e.g., index = 0,1,2,...).

Parameters
indexZero based sample position

Definition at line 368 of file QuickFilter.cpp.

int Isis::QuickFilter::Count ( const int  index)

Computes and returns the number of valid pixels in the boxcar at pixel index (zero based).

No error checks are done for out of array bounds conditions. The routine works the fastest when sequentially accessing the counts (e.g., index = 0,1,2,...).

Parameters
indexZero based sample position
Returns
double

Definition at line 276 of file QuickFilter.cpp.

int Isis::QuickFilter::HalfHeight ( ) const

Returns the half the height of the boxcar rounded down because the boxcar size is odd.

Returns
int

Definition at line 318 of file QuickFilter.cpp.

Referenced by Isis::ProcessByQuickFilter::StartProcess().

int Isis::QuickFilter::HalfWidth ( ) const

Returns the half the width of the boxcar rounded down because the boxcar size is odd.

Returns
int

Definition at line 299 of file QuickFilter.cpp.

int Isis::QuickFilter::Height ( ) const

Returns the height of the boxcar.

Returns
int

Definition at line 308 of file QuickFilter.cpp.

double Isis::QuickFilter::High ( ) const

Returns the highest pixel value included in filtering computations.

Returns
double

Definition at line 345 of file QuickFilter.cpp.

double Isis::QuickFilter::Low ( ) const

Returns the lowest pixel value included in filtering computations.

Returns
double

Definition at line 336 of file QuickFilter.cpp.

int Isis::QuickFilter::MinimumPixels ( ) const

Returns the minimum number of pixels which need to be valid inside the boxcar.

If there are not enough valid pixels then invoking Average and Variance methods will result in a NULL output.

Returns
int

Definition at line 356 of file QuickFilter.cpp.

void Isis::QuickFilter::RemoveLine ( const double *  buf)

Remove an array of doubles from the accumulators and counters.

Parameters
bufPointer to array of doubles to remove

Definition at line 204 of file QuickFilter.cpp.

References Isis::IsValidPixel().

Referenced by Isis::ProcessByQuickFilter::StartProcess().

void Isis::QuickFilter::Reset ( )

Reset all accumulators and counters to zero.

Definition at line 95 of file QuickFilter.cpp.

Referenced by Isis::ProcessByQuickFilter::StartProcess().

int Isis::QuickFilter::Samples ( ) const

Returns the number of samples in a line.

Returns
int

Definition at line 327 of file QuickFilter.cpp.

void Isis::QuickFilter::SetMinimumPixels ( const int  pixels)

This method is used to set the minimum number of valid pixels in the boxcar.

If the minimum requirement can not be satisfied then the Average and Variance methods will return Isis:NULL8. The default value is zero.

Parameters
pixelsNumber of minimum valid pixels for statistically computations to occur
Exceptions
Isis::iException::Programmer

Definition at line 155 of file QuickFilter.cpp.

References _FILEINFO_.

Referenced by Isis::ProcessByQuickFilter::StartProcess().

void Isis::QuickFilter::SetMinMax ( const double  minimum,
const double  maximum 
)

This method is used to set the minimum/maximum valid values.

Pixels are only considered valid (usable when computing Average and Variance) if they are not special (NULL, LIS, etc) and if they fall within the range of minimum and maximum inclusive. You should only invoke this method once after the object has been constructed. Further invocations will cause unpredictable results. If this method is never called then the defaults are DBL_MIN and DBL_MAX, respectively.

Parameters
minimumMinimum valid pixel
maximumMaximum valid pixel
Exceptions
Isis::iException::Programmer

Definition at line 134 of file QuickFilter.cpp.

References _FILEINFO_.

Referenced by Isis::ProcessByQuickFilter::StartProcess().

double Isis::QuickFilter::Variance ( const int  index)

Computes and returns the boxcar variance at pixel index (zero based).

No error checks are done for out of array bounds conditions. If there are not enough valid pixels in the boxcar then Isis::NULL8 is returned. The routine works the fastest when sequentially accessing the variances (e.g., index = 0,1,2,...).

Parameters
indexZero based sample position
Returns
double

Definition at line 252 of file QuickFilter.cpp.

int Isis::QuickFilter::Width ( ) const

Returns the width of the boxcar.

Returns
int

Definition at line 289 of file QuickFilter.cpp.

Member Data Documentation

int* Isis::QuickFilter::p_counts
private

    This is identical to p_sums with the exception

that it keeps count of the number of valid pixels in p_sums and p_sumsqrs.

A valid pixel is considered to be not special (NULL, LIS, HIS, etc) and within the range of p_minimum and p_maximum. Therefore, p_counts[i] for any i is a number between 0 and M (number of lines in the boxcar) depending on the number of valid pixels.

Definition at line 82 of file QuickFilter.h.

int Isis::QuickFilter::p_halfHeight
private

    This is half the height of the boxcar rounded

down to the next integer since the boxcar is always odd.

For example, p_height=5 implies p_halfHeight=2 (5/2 = 2.5 = 2). It is used for internal computations within Average, Variance, and Count methods.

Definition at line 132 of file QuickFilter.h.

int Isis::QuickFilter::p_halfWidth
private

     This is half the width of the boxcar rounded

down to the next integer since the boxcar is always odd.

For example, p_width=5 implies p_halfWidth=2 (5/2 = 2.5 = 2). It is used for internal computations within Average, Variance, and Count methods.

Definition at line 121 of file QuickFilter.h.

int Isis::QuickFilter::p_height
private

This is the height of the boxcar.

It is set in the constructor using a parameter passed into the constructor. It must be positive and odd and is used in the Average, Variance, and Count methods.

Definition at line 127 of file QuickFilter.h.

int Isis::QuickFilter::p_lastCount
private

See p_lastSum.

Definition at line 152 of file QuickFilter.h.

int Isis::QuickFilter::p_lastIndex
private

      This is used to keep track of the last index

passed into the Average, Variance and/or count method.

If the index is the same as p_lastIndex then computations are trival. If the index has increased by one then the next accumulator will be added and the first accumulator will be removed from p_lastSum, p_lastSumsqr,and p_latCount. This speed processing. Others the entire boxcar needs to be recomputed. This generally happens when a new line is added or the programmer bounces around with the index.

Definition at line 153 of file QuickFilter.h.

double Isis::QuickFilter::p_lastSum
private

The last sum of a full boxcar.

That is using the width of the boxcar (assume 3) p_lastSum = p_sums[0] + p_sums[1] + p_sums[2] at sample 2. At sample 3, p_lastSum = p_sums[1] + p_sums[2] + p_sums[3]. If the programmer makes ordered calls to the Average, Variance, and/or Count methods we can speed those routines. For example, p_lastSum += p_sums[4] - p_sums[1] would be correct for sample 4. This will make a significant difference in speed if p_width is large.

Definition at line 139 of file QuickFilter.h.

double Isis::QuickFilter::p_lastSumsqr
private

See p_lastSum.

Definition at line 151 of file QuickFilter.h.

int Isis::QuickFilter::p_linesAdded
private

     This is used to keep track of the number of

lines added.

If the programmer adds more lines than the height of the boxcar, an error will be thrown.

Definition at line 164 of file QuickFilter.h.

double Isis::QuickFilter::p_maximum
private

Maximum valid pixel value.

It is set to DBL_MAX in the constructor and can be changed using the protected method SetMinMax. It is used to evaluate input pixels to determine if they are valid. A pixel will be accumulated in p_sums, p_sumsqrs, and p_counts, if it is within the range of p_minimum and p_maximum.

Definition at line 103 of file QuickFilter.h.

double Isis::QuickFilter::p_minimum
private

Minimum valid pixel value.

It is set to DBL_MIN in the constructor and can be changed using the protected method SetMinMax. It is used to evaluate input pixels to determine if they are valid. A pixel will be accumulated in p_sums, p_sumsqrs, and p_counts, if it is within the range of p_minimum and p_maximum.

Definition at line 96 of file QuickFilter.h.

int Isis::QuickFilter::p_minimumPixels
private

 The minimum number of pixels in the boxcar which

must be valid (not special and inside p_minimum/p_maximum) in order for Average and Variance to compute a value.

If there are not enough valid pixels then those methods will return Isis::NULL8;

Definition at line 110 of file QuickFilter.h.

int Isis::QuickFilter::p_ns
private

This value is initialized in the constructor.

It is set using the value passed into the constructor. It represents the number of samples across the image. It will be used to allocate internal buffers.

Definition at line 90 of file QuickFilter.h.

double* Isis::QuickFilter::p_sums
private

Sum accumulator for each column/sample.

This array is allocated to the size of p_ns. For each column in the cube, this array will contain the sum of M lines at the particular sample position. For example, if M=3 and we had loaded lines 3,4,5 using AddLine then p_sum[0] = cube(1,3) + cube(1,4) + cube(1,5), where cube(sample,line) is the value at the position in the cube. The sums are used to compute the average.

Definition at line 68 of file QuickFilter.h.

double* Isis::QuickFilter::p_sumsqrs
private

This is identical to p_sums with the exception

that the pixel values are squared before summing occurs.

This of course is needed to compute the variance.

Definition at line 78 of file QuickFilter.h.

int Isis::QuickFilter::p_width
private

This is the width of the boxcar.

It is set in the constructor using a parameter passed into the constructor. It must be positive and odd and is used in the Average, Variance, and Count methods.

Definition at line 116 of file QuickFilter.h.


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