Isis 3 Programmer Reference
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 50 of file QuickFilter.h.

Constructor & Destructor Documentation

◆ QuickFilter()

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 27 of file QuickFilter.cpp.

References p_counts, p_halfHeight, p_halfWidth, p_height, p_maximum, p_minimum, p_minimumPixels, p_ns, p_sums, p_sumsqrs, p_width, Isis::IException::Programmer, and Reset().

◆ ~QuickFilter()

Isis::QuickFilter::~QuickFilter ( )

Destroys the QuickFilter object.

Definition at line 97 of file QuickFilter.cpp.

References p_counts, p_sums, and p_sumsqrs.

Member Function Documentation

◆ AddLine()

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 162 of file QuickFilter.cpp.

References Isis::IsValidPixel(), p_counts, p_height, p_lastIndex, p_linesAdded, p_maximum, p_minimum, p_ns, p_sums, p_sumsqrs, and Isis::IException::Programmer.

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

◆ Average()

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 213 of file QuickFilter.cpp.

References Compute(), p_lastCount, p_lastSum, and p_minimumPixels.

◆ Compute()

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 352 of file QuickFilter.cpp.

References p_counts, p_halfWidth, p_lastCount, p_lastIndex, p_lastSum, p_lastSumsqr, p_ns, p_sums, and p_sumsqrs.

Referenced by Average(), Count(), and Variance().

◆ Count()

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 260 of file QuickFilter.cpp.

References Compute(), and p_lastCount.

◆ HalfHeight()

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 302 of file QuickFilter.cpp.

References p_halfHeight.

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

◆ HalfWidth()

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 283 of file QuickFilter.cpp.

References p_halfWidth.

◆ Height()

int Isis::QuickFilter::Height ( ) const

Returns the height of the boxcar.

Returns
int

Definition at line 292 of file QuickFilter.cpp.

References p_height.

◆ High()

double Isis::QuickFilter::High ( ) const

Returns the highest pixel value included in filtering computations.

Returns
double

Definition at line 329 of file QuickFilter.cpp.

References p_maximum.

◆ Low()

double Isis::QuickFilter::Low ( ) const

Returns the lowest pixel value included in filtering computations.

Returns
double

Definition at line 320 of file QuickFilter.cpp.

References p_minimum.

◆ MinimumPixels()

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 340 of file QuickFilter.cpp.

References p_minimumPixels.

◆ RemoveLine()

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 188 of file QuickFilter.cpp.

References Isis::IsValidPixel(), p_counts, p_lastIndex, p_linesAdded, p_maximum, p_minimum, p_ns, p_sums, and p_sumsqrs.

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

◆ Reset()

void Isis::QuickFilter::Reset ( )

Reset all accumulators and counters to zero.

Definition at line 79 of file QuickFilter.cpp.

References p_counts, p_lastCount, p_lastIndex, p_lastSum, p_lastSumsqr, p_linesAdded, p_ns, p_sums, and p_sumsqrs.

Referenced by QuickFilter(), and Isis::ProcessByQuickFilter::StartProcess().

◆ Samples()

int Isis::QuickFilter::Samples ( ) const

Returns the number of samples in a line.

Returns
int

Definition at line 311 of file QuickFilter.cpp.

References p_ns.

◆ SetMinimumPixels()

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 139 of file QuickFilter.cpp.

References p_height, p_minimumPixels, p_width, and Isis::IException::Programmer.

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

◆ SetMinMax()

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 118 of file QuickFilter.cpp.

References p_lastIndex, p_maximum, p_minimum, and Isis::IException::Programmer.

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

◆ Variance()

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 236 of file QuickFilter.cpp.

References Compute(), p_lastCount, p_lastSum, p_lastSumsqr, and p_minimumPixels.

◆ Width()

int Isis::QuickFilter::Width ( ) const

Returns the width of the boxcar.

Returns
int

Definition at line 273 of file QuickFilter.cpp.

References p_width.

Member Data Documentation

◆ p_counts

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 66 of file QuickFilter.h.

Referenced by AddLine(), Compute(), QuickFilter(), RemoveLine(), Reset(), and ~QuickFilter().

◆ p_halfHeight

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 116 of file QuickFilter.h.

Referenced by HalfHeight(), and QuickFilter().

◆ p_halfWidth

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 105 of file QuickFilter.h.

Referenced by Compute(), HalfWidth(), and QuickFilter().

◆ p_height

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 111 of file QuickFilter.h.

Referenced by AddLine(), Height(), QuickFilter(), and SetMinimumPixels().

◆ p_lastCount

int Isis::QuickFilter::p_lastCount
private

See p_lastSum.

Definition at line 136 of file QuickFilter.h.

Referenced by Average(), Compute(), Count(), Reset(), and Variance().

◆ p_lastIndex

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 137 of file QuickFilter.h.

Referenced by AddLine(), Compute(), RemoveLine(), Reset(), and SetMinMax().

◆ p_lastSum

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 123 of file QuickFilter.h.

Referenced by Average(), Compute(), Reset(), and Variance().

◆ p_lastSumsqr

double Isis::QuickFilter::p_lastSumsqr
private

See p_lastSum.

Definition at line 135 of file QuickFilter.h.

Referenced by Compute(), Reset(), and Variance().

◆ p_linesAdded

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 148 of file QuickFilter.h.

Referenced by AddLine(), RemoveLine(), and Reset().

◆ p_maximum

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 87 of file QuickFilter.h.

Referenced by AddLine(), High(), QuickFilter(), RemoveLine(), and SetMinMax().

◆ p_minimum

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 80 of file QuickFilter.h.

Referenced by AddLine(), Low(), QuickFilter(), RemoveLine(), and SetMinMax().

◆ p_minimumPixels

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 94 of file QuickFilter.h.

Referenced by Average(), MinimumPixels(), QuickFilter(), SetMinimumPixels(), and Variance().

◆ p_ns

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 74 of file QuickFilter.h.

Referenced by AddLine(), Compute(), QuickFilter(), RemoveLine(), Reset(), and Samples().

◆ p_sums

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 52 of file QuickFilter.h.

Referenced by AddLine(), Compute(), QuickFilter(), RemoveLine(), Reset(), and ~QuickFilter().

◆ p_sumsqrs

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 62 of file QuickFilter.h.

Referenced by AddLine(), Compute(), QuickFilter(), RemoveLine(), Reset(), and ~QuickFilter().

◆ p_width

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 100 of file QuickFilter.h.

Referenced by QuickFilter(), SetMinimumPixels(), and Width().


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