Loading...
Searching...
No Matches
casacore::ImageStatistics< T > Class Template Reference
images package (libcasa_images) » Images_module

More...

`#include <ImageStatistics.h>`

## Public Member Functions

| ImageStatistics (const ImageInterface< T > &image, LogIO &os, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
| Constructor takes the image and a LogIO object for logging.
| ImageStatistics (const ImageInterface< T > &image, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
| Constructor takes the image only.
| ImageStatistics (const ImageStatistics< T > &other)
| Copy constructor.
virtual | ~ImageStatistics ()
| Destructor.
ImageStatistics< T > & | operator= (const ImageStatistics< T > &other)
| Assignment operator.
Bool | setNewImage (const ImageInterface< T > &image, Bool clone=True)
| Set a new ImageInterface object.
void | setPrecision (Int precision)
void | setBlc (const IPosition &blc)
IPosition | getBlc () const
Int | getPrecision () const
void | showRobust (const Bool show)
| list robust statistics?
void | recordMessages (const Bool rm)
vector< String > | getMessages ()
void | clearMessages ()
void | setListStats (Bool b)
Public Member Functions inherited from casacore::LatticeStatistics< T >
| LatticeStatistics (const MaskedLattice< T > &lattice, LogIO &os, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
| Constructor takes the lattice and a LogIO object for logging.
| LatticeStatistics (const MaskedLattice< T > &lattice, Bool showProgress=True, Bool forceDisk=False, Bool clone=True)
| Constructor takes the lattice only.
| LatticeStatistics (const LatticeStatistics< T > &other)
| Copy constructor.
virtual | ~LatticeStatistics ()
| Destructor.
LatticeStatistics< T > & | operator= (const LatticeStatistics< T > &other)
| Assignment operator.
Bool | setAxes (const Vector< Int > &cursorAxes)
| Set the cursor axes (0 relative).
Bool | setInExCludeRange (const Vector< T > &include, const Vector< T > &exclude, Bool setMinMaxToInclude=False)
| You may specify a pixel intensity range as either one for which all pixels in that range are included or one for which all pixels in that range are excluded.
Bool | setList (const Bool &doList)
| This function allows you to control whether the statistics are written to the output stream if you are also making a plot.
Bool | display ()
| Display the statistics by listing and/or plotting them.
Bool | getLayerStats (String &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
Bool | getLayerStats (stat_list &stats, Double area, Int zAxis=-1, Int zLayer=-1, Int hAxis=-1, Int hLayer=-1)
Vector< Int > | displayAxes () const
| Return the display axes.
Bool | getStatistic (Array< AccumType > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
| Recover the desired Statistic into an array.
Bool | getConvertedStatistic (Array< T > &stat, LatticeStatsBase::StatisticsTypes type, Bool dropDeg=True)
Bool | getMinMaxPos (IPosition &minPos, IPosition &maxPos)
| Recover position of min and max.
Bool | getStats (Vector< AccumType > &, const IPosition &pos, const Bool posInLattice=False)
| This function gets a vector containing all the statistics for a given location.
void | resetError ()
| Reset argument error condition.
Bool | getFullMinMax (T &dataMin, T &dataMax)
| Get full lattice min and max only.
String | errorMessage () const
| Recover last error message.
Bool | setNewLattice (const MaskedLattice< T > &lattice, Bool clone=True)
| Set a new MaskedLattice object.
Bool | hasLogger () const
| Did we construct with a logger ?
Bool | configureBiweight (Int maxIter, Double c)
| The configure methods return True if reconfiguration is actually necessary (ie if the underlying storage lattice needs to be recomputed).
Bool | configureClassical ()
| configure object to use Classical Statistics The time, t_x, it takes to compute classical statistics using algorithm x, can be modeled by t_x = n_sets*(a_x + b_x*n_el) where n_sets is the number of independent sets of data to compute stats on, each containing n_el number of elements.
Bool | configureClassical (Double aOld, Double bOld, Double aNew, Double bNew)
Bool | configureFitToHalf (FitToHalfStatisticsData::CENTER centerType=FitToHalfStatisticsData::CMEAN, FitToHalfStatisticsData::USE_DATA useData=FitToHalfStatisticsData::LE_CENTER, AccumType centerValue=0)
| configure to use fit to half algorithm.
Bool | configureHingesFences (Double f)
| configure to use hinges-fences algorithm
Bool | configureChauvenet (Double zscore=-1, Int maxIterations=-1)
| configure to use Chauvenet's criterion
void | forceUseStatsFrameworkUsingDataProviders ()
| The force* methods are really only for testing.
void | forceUseStatsFrameworkUsingArrays ()
void | forceUseOldTiledApplyMethod ()
void | forceAllowCodeDecideWhichAlgortihmToUse ()
std::map< String, uInt > | getChauvenetNiter () const
| get number of iterations associated with Chauvenet criterion algorithm
void | setComputeQuantiles (Bool b)
| should quantile-like stats (median, quartiles, medabsdevmed) be computed?

## Protected Types

typedef NumericTraits< T >::PrecisionType | AccumType

## Protected Member Functions

virtual Bool | _canDoFlux () const
| Virtual Functions.
Protected Member Functions inherited from casacore::LatticeStatistics< T >
virtual Bool | listLayerStats (const Matrix< AccumType > &ord, ostringstream &rslt, Int zLayer)
IPosition | locInLattice (const IPosition &storagePosition, Bool relativeToParent=True) const
| Given a location in the storage lattice, convert those locations on the non-statistics axis (the last one) and optionally account for the lattice subsectioning.
void | setStream (ostream &os, Int oPrec)
| Non-virtual functions.
IPosition | _storageLatticeShape () const
| get the storage lattice shape
void | _latticePosToStoragePos (IPosition &storagePos, const IPosition &latticePos)
| convert a position in the input lattice to the corresponding position in the stats storage lattice.
StatisticsData::ALGORITHM | _getAlgorithm () const

## Private Member Functions

virtual void | getLabels (String &higherOrder, String &xAxis, const IPosition &dPos) const
| Virtual functions.
virtual Bool | _getBeamArea (Array< Double > &beamArea, String &msg) const
| Get beam area in pixels if possible.
virtual void | listMinMax (ostringstream &osMin, ostringstream &osMax, Int oWidth, DataType type)
| List min and max with world coordinates.
virtual Bool | listStats (Bool hasBeam, const IPosition &dPos, const Matrix< AccumType > &ord)
| List the statistics.
virtual void | displayStats (AccumType nPts, AccumType sum, AccumType median, AccumType medAbsDevMed, AccumType quartile, AccumType sumSq, AccumType mean, AccumType var, AccumType rms, AccumType sigma, AccumType dMin, AccumType dMax, AccumType q1, AccumType q3)
Quantum< AccumType > | _flux (Bool &isFluxDensity, AccumType sum, Double beamAreaInPixels) const
| If isFluxDensity is False, then the computed value is a flux (ie flux density integrated over a spectral extent).
Bool | _computeFlux (Array< AccumType > &flux, const Array< AccumType > &npts, const Array< AccumType > &sum)
Bool | _computeFlux (Quantum< AccumType > &flux, AccumType sum, const IPosition &pos, Bool posInLattice)

## Private Attributes

LogIO | os_p
| Data.
const ImageInterface< T > * | pInImage_p
std::shared_ptr< const ImageInterface< T > > | _inImPtrMgr
IPosition | blc_
Int | precision_
Bool | _showRobust
Bool | _recordMessages
Bool | _listStats
vector< String > | _messages

## Additional Inherited Members

Public Types inherited from casacore::LatticeStatistics< T >
typedef NumericTraits< T >::PrecisionType | AccumType
typedef std::pair< String, String > | stat_element
typedef std::list< stat_element > | stat_list
Public Types inherited from casacore::LatticeStatsBase
enum | StatisticsTypes { NPTS , SUM , SUMSQ , MEDIAN , MEDABSDEVMED , QUARTILE , Q1 , Q3 , MIN , MAX , MEAN , VARIANCE , SIGMA , RMS , FLUX , NSTATS , NACCUM }
| This enum StatisticTypes is provided for use with the LatticeStatistics<T>::setPlotting function. More...
Static Public Member Functions inherited from casacore::LatticeStatsBase
static Vector< Int > | toStatisticTypes (const String &statistics, const std::regex &delimiter)
| Helper function to convert a String containing a list of desired statistics to the correct Vector<Int> required for the LatticeStatistics<T>::setPlotting function.
static Vector< Int > | toStatisticTypes (const Vector< String > &statistics)
static String | toStatisticName (StatisticsTypes type)
| Convert type to string.
static String | toStatisticName (Int type)
static Int | toStatisticType (const String &statistic)
| Returns -1 if the statistic string is not valid.
static Bool | setNxy (Vector< Int > &nxy, ostream &os)
| Check and fill in defaults for a Vector<Int> containing the number of subplots in x and y to be put on a plot.
static void | setStorageImageShape (IPosition &storeImageShape, const Bool &last, const Int &axisSize, const Vector< Int > &displayAxes, const IPosition &shape)
| A storage image is used to accumulate information as a function of the display axes as an image is iterated through.
static void | stretchMinMax (Float &min, Float &max)
| Stretch a range by 10%.
static std::set< Double > | quartileFracs ()
Protected Attributes inherited from casacore::LatticeStatistics< T >
LogIO | os_p
Vector< Int > | cursorAxes_p
Vector< Int > | displayAxes_p
Bool | goodParameterStatus_p
Bool | haveLogger_p
Bool | fixedMinMax_p
Bool | doRobust_p
| doRobust means that when the storage lattice is generated, the robust statistics are generated as well
Bool | doList_p
IPosition | minPos_p
IPosition | maxPos_p
IPosition | blcParent_p
String | error_p

## Detailed Description

template<class T>
class casacore::ImageStatistics< T >

Displays various statistics from an image.

### Intended use:

Public interface

### Review Status

Date Reviewed:
  yyyy/mm/dd

### Prerequisite

- LatticeStatistics (base class)
- ImageInterface

### Etymology

This is a class designed to display and retrieve statistics from images

### Synopsis

This class enable you to display and/or retrieve statistics evaluated over specified regions from an image. The dimension of the region is arbitrary, but the size of each dimension is always the size of the corresponding image axis. The statistics are displayed as a function of location of the axes not used to evaluate the statistics over. The axes which you evaluate the statistics over are called the cursor axes, the others are called the display axes.

This class is derived from the class LatticeStatistics which does all the work. This class only adds some extra capability in terms of logging world (rather than pixel) coordinates and computing the synthesized beam area, if there is one. There are just a few virtual functions for you to over-ride. These are rather specialized, they are not part of a general polymorphic interface, just a way to separate the Lattice and Image functionality out.

See LatticeStatistics for details and examples.

### Motivation

The generation of statistical information from an image is a basic and necessary capability.

### To Do

- Deal with complex images at least for statistics retrieval if not plotting.
- Retrieve statistics at specified location of display axes
- Standard errors on statistical quantities
- Median, other more exotic statistics. Life made difficult by accumulation image approach

Definition at line 97 of file ImageStatistics.h.

## Member Typedef Documentation

## AccumType

template<class T>

typedef NumericTraits<T>::PrecisionType casacore::ImageStatistics< T >::AccumType

protected

Definition at line 171 of file ImageStatistics.h.

## Constructor & Destructor Documentation

## ImageStatistics() [1/3]

template<class T>

casacore::ImageStatistics< T >::ImageStatistics | ( | const ImageInterface< T > & | image,
|  | LogIO & | os,
|  | Bool | showProgress = True,
|  | Bool | forceDisk = False,
|  | Bool | clone = True )

Constructor takes the image and a LogIO object for logging.

You can specify whether you want to see progress meters or not. You can force the storage image to be disk based, otherwise the decision for core or disk is taken for you. If clone is True, the input image will be cloned, so the caller can make changes to the input image, but the statistics will reflect the image as it was at construction. If False, a reference to the input image is used, and so the caller shouldn't make changes to the input image between construction and calling statistics computation methods, unless it calls setNewImage() to update the changed image. Obviously, cloning the image impacts performance and memory usage.

References casacore::clone(), casacore::False, and casacore::True.

Referenced by ImageStatistics(), and operator=().

## ImageStatistics() [2/3]

template<class T>

casacore::ImageStatistics< T >::ImageStatistics | ( | const ImageInterface< T > & | image,
|  | Bool | showProgress = True,
|  | Bool | forceDisk = False,
|  | Bool | clone = True )

Constructor takes the image only.

In the absence of a logger you get no messages. This includes error messages and potential listing of the statistics. You can specify whether you want to see progress meters or not. You can force the storage image to be disk based, otherwise the decision for core or disk is taken for you.

References casacore::clone(), casacore::False, and casacore::True.

## ImageStatistics() [3/3]

template<class T>

casacore::ImageStatistics< T >::ImageStatistics | ( | const ImageStatistics< T > & | other | ) |

Copy constructor.

Copy semantics are followed. Therefore any storage image that has already been created for other is copied to *this

References ImageStatistics().

## ~ImageStatistics()

template<class T>

virtual casacore::ImageStatistics< T >::~ImageStatistics | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## _canDoFlux()

template<class T>

virtual Bool casacore::ImageStatistics< T >::_canDoFlux | ( |  | ) | const

protected virtual

Virtual Functions.

See implementation to figure it all out !

FIXME The indirect dependence of this class on ImageInterface related issues (eg flux density) breaks encapsulation. All the ImageInterface related code should be encapsulated in ImageStatistics. Unfortunately, that requires significantly more time than I have atm. A return value of False means that the object in question cannot compute flux density values. The default implementation returns False.

Reimplemented from casacore::LatticeStatistics< T >.

## _computeFlux() [1/2]

template<class T>

Bool casacore::ImageStatistics< T >::_computeFlux | ( | Array< AccumType > & | flux,
|  | const Array< AccumType > & | npts,
|  | const Array< AccumType > & | sum )

private virtual

Reimplemented from casacore::LatticeStatistics< T >.

References casacore::sum().

## _computeFlux() [2/2]

template<class T>

Bool casacore::ImageStatistics< T >::_computeFlux | ( | Quantum< AccumType > & | flux,
|  | AccumType | sum,
|  | const IPosition & | pos,
|  | Bool | posInLattice )

private virtual

Reimplemented from casacore::LatticeStatistics< T >.

References casacore::LatticeStatistics< T >::blcParent_p, casacore::LatticeStatistics< T >::cursorAxes_p, casacore::LatticeStatistics< T >::displayAxes_p, casacore::LatticeStatistics< T >::doList_p, casacore::LatticeStatistics< T >::doRobust_p, casacore::LatticeStatistics< T >::error_p, casacore::LatticeStatistics< T >::fixedMinMax_p, casacore::LatticeStatsBase::FLUX, casacore::LatticeStatistics< T >::goodParameterStatus_p, casacore::LatticeStatistics< T >::haveLogger_p, casacore::LatticeStatistics< T >::LatticeStatistics(), casacore::LatticeStatistics< T >::locInLattice(), casacore::LatticeStatsBase::MAX, casacore::LatticeStatistics< T >::maxPos_p, casacore::LatticeStatsBase::MEAN, casacore::LatticeStatsBase::MEDIAN, casacore::LatticeStatsBase::MIN, casacore::LatticeStatistics< T >::minPos_p, casacore::LatticeStatsBase::NPTS, casacore::LatticeStatsBase::RMS, casacore::LatticeStatistics< T >::setStream(), casacore::LatticeStatsBase::SIGMA, casacore::LatticeStatsBase::SUM, and casacore::sum().

## _flux()

template<class T>

Quantum< AccumType > casacore::ImageStatistics< T >::_flux | ( | Bool & | isFluxDensity,
|  | AccumType | sum,
|  | Double | beamAreaInPixels ) const

private virtual

If isFluxDensity is False, then the computed value is a flux (ie flux density integrated over a spectral extent).

Reimplemented from casacore::LatticeStatistics< T >.

References casacore::sum().

## _getBeamArea()

template<class T>

virtual Bool casacore::ImageStatistics< T >::_getBeamArea | ( | Array< Double > & | beamArea,
|  | String & | msg ) const

private virtual

Get beam area in pixels if possible.

Return False if the beam area could not be calculated.

## clearMessages()

template<class T>

void casacore::ImageStatistics< T >::clearMessages | ( |  | ) |

inline

Definition at line 166 of file ImageStatistics.h.

References _messages.

## displayStats()

template<class T>

virtual void casacore::ImageStatistics< T >::displayStats | ( | AccumType | nPts,
|  | AccumType | sum,
|  | AccumType | median,
|  | AccumType | medAbsDevMed,
|  | AccumType | quartile,
|  | AccumType | sumSq,
|  | AccumType | mean,
|  | AccumType | var,
|  | AccumType | rms,
|  | AccumType | sigma,
|  | AccumType | dMin,
|  | AccumType | dMax,
|  | AccumType | q1,
|  | AccumType | q3 )

private virtual

Reimplemented from casacore::LatticeStatistics< T >.

References casacore::mean(), casacore::median(), casacore::rms(), and casacore::sum().

## getBlc()

template<class T>

IPosition casacore::ImageStatistics< T >::getBlc | ( |  | ) | const

## getLabels()

template<class T>

virtual void casacore::ImageStatistics< T >::getLabels | ( | String & | higherOrder,
|  | String & | xAxis,
|  | const IPosition & | dPos ) const

private virtual

Virtual functions.

See LatticeStatistics for more information about these, or see the implementation.

Get label for higher order axes

## getMessages()

template<class T>

vector< String > casacore::ImageStatistics< T >::getMessages | ( |  | ) |

inline

Definition at line 164 of file ImageStatistics.h.

References _messages.

## getPrecision()

template<class T>

Int casacore::ImageStatistics< T >::getPrecision | ( |  | ) | const

## listMinMax()

template<class T>

virtual void casacore::ImageStatistics< T >::listMinMax | ( | ostringstream & | osMin,
|  | ostringstream & | osMax,
|  | Int | oWidth,
|  | DataType | type )

private virtual

List min and max with world coordinates.

Reimplemented from casacore::LatticeStatistics< T >.

## listStats()

template<class T>

virtual Bool casacore::ImageStatistics< T >::listStats | ( | Bool | hasBeam,
|  | const IPosition & | dPos,
|  | const Matrix< AccumType > & | ord )

private virtual

List the statistics.

Reimplemented from casacore::LatticeStatistics< T >.

## operator=()

template<class T>

ImageStatistics< T > & casacore::ImageStatistics< T >::operator= | ( | const ImageStatistics< T > & | other | ) |

Assignment operator.

Deletes any storage image associated with the object being assigned to and copies any storage image that has already been created for "other".

References ImageStatistics().

## recordMessages()

template<class T>

void casacore::ImageStatistics< T >::recordMessages | ( | const Bool | rm | ) |

inline

Definition at line 162 of file ImageStatistics.h.

References _recordMessages.

## setBlc()

template<class T>

void casacore::ImageStatistics< T >::setBlc | ( | const IPosition & | blc | ) |

## setListStats()

template<class T>

void casacore::ImageStatistics< T >::setListStats | ( | Bool | b | ) |

inline

Definition at line 168 of file ImageStatistics.h.

References _listStats.

## setNewImage()

template<class T>

Bool casacore::ImageStatistics< T >::setNewImage | ( | const ImageInterface< T > & | image,
|  | Bool | clone = True )

Set a new ImageInterface object.

A return value of False indicates the image had an invalid type or that the internal state of the class is bad. If clone is True, the input image will be cloned, so the caller can make changes to the input image, but the statistics will reflect the image as it was at construction. If False, a reference to the input image is used, and so the caller shouldn't make changes to the input image between construction and calling statistics computation methods, unless it calls setNewImage() to update the changed image. Obviously, cloning the image impacts performance and memory usage.

References casacore::clone(), and casacore::True.

## setPrecision()

template<class T>

void casacore::ImageStatistics< T >::setPrecision | ( | Int | precision | ) |

## showRobust()

template<class T>

void casacore::ImageStatistics< T >::showRobust | ( | const Bool | show | ) |

list robust statistics?

Should be called before display()

## Member Data Documentation

## _inImPtrMgr

template<class T>

std::shared_ptr<const ImageInterface<T> > casacore::ImageStatistics< T >::_inImPtrMgr

private

Definition at line 180 of file ImageStatistics.h.

## _listStats

template<class T>

Bool casacore::ImageStatistics< T >::_listStats

private

Definition at line 183 of file ImageStatistics.h.

Referenced by setListStats().

## _messages

template<class T>

vector<String> casacore::ImageStatistics< T >::_messages

mutable private

Definition at line 184 of file ImageStatistics.h.

Referenced by clearMessages(), and getMessages().

## _recordMessages

template<class T>

Bool casacore::ImageStatistics< T >::_recordMessages

private

Definition at line 183 of file ImageStatistics.h.

Referenced by recordMessages().

## _showRobust

template<class T>

Bool casacore::ImageStatistics< T >::_showRobust

private

Definition at line 183 of file ImageStatistics.h.

## blc_

template<class T>

IPosition casacore::ImageStatistics< T >::blc_

private

Definition at line 181 of file ImageStatistics.h.

## os_p

template<class T>

LogIO casacore::ImageStatistics< T >::os_p

private

Data.

Definition at line 178 of file ImageStatistics.h.

## pInImage_p

template<class T>

const ImageInterface<T>* casacore::ImageStatistics< T >::pInImage_p

private

Definition at line 179 of file ImageStatistics.h.

## precision_

template<class T>

Int casacore::ImageStatistics< T >::precision_

private

Definition at line 182 of file ImageStatistics.h.

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

- images/Images/ImageStatistics.h