15 #ifndef __IPSDKMATH_BASEHISTOGRAM_H__ 16 #define __IPSDKMATH_BASEHISTOGRAM_H__ 20 #pragma warning (push) 21 #pragma warning (disable : 4251) 29 #include <IPSDKMath/Clustering/KMeansClusteringConfig.h> 30 #include <IPSDKMath/Clustering/KernelKMeansClusteringConfig.h> 31 #include <IPSDKSerialization/Engine/BaseSerializationObject.h> 69 void initFromExisting(
const ipReal64 firstHistoValue,
92 virtual ipBool areDataIntegral()
const = 0;
148 ipUInt32 getLowerOutOfBoundsBinIdx()
const;
155 ipUInt32 getUpperOutOfBoundsBinIdx()
const;
160 ipUInt32 getInBoundsBinOffset()
const;
170 ipUInt64 getTotalPopulation()
const;
295 void getCumulatedFrequencies(
Real64Vector& cumulatedFrequencies)
const;
313 ipUInt32 getMaxPopulationClassIdx()
const;
335 const ipUInt64 populationThreshold = 0)
const;
371 const ipUInt64 populationThreshold = 0)
const;
411 const bool bIncludeOutOfBoundsData =
false)
const;
420 const bool bIncludeOutOfBoundsData =
false,
428 template <
typename KernelType>
429 boost::shared_ptr<clustering::KernelKMeansClustering<KernelType> >
430 applyKernelKMeansClustering(
const ipUInt32 nbClusters,
431 const KernelType& kernel,
432 const bool bIncludeOutOfBoundsData =
false,
440 template <
typename KernelType>
441 boost::shared_ptr<clustering::SpectralClustering<KernelType> >
442 applySpectralClustering(
const ipUInt32 nbClusters,
443 const KernelType& kernel,
444 const bool bIncludeOutOfBoundsData =
false,
453 void checkInit()
const;
456 void checkClassIdx(
const ipUInt32 classIdx)
const;
459 void checkBinIdx(
const ipUInt32 classIdx)
const;
466 void updateHistogramParams(
const ipReal64 firstHistoValue,
476 void updateHistogramParams(
const ipReal64 firstHistoValue,
486 void clearCumulatedData();
489 void collectClusteringData(
const bool bIncludeOutOfBoundsData,
502 void updateCumulatedIfNeeded()
const;
505 void updateCumulated()
const;
540 IPSDK_FORCEINLINE
bool 543 return _nbClasses != 0;
552 return _firstHistoValue;
561 return _lastHistoValue;
609 return static_cast<ipUInt32>(_histogramPopulation.size());
618 return _lowerOutOfBoundsBinIdx;
627 return _upperOutOfBoundsBinIdx;
636 return _inBoundsBinOffset;
645 return _histogramPopulation;
652 updateCumulatedIfNeeded();
654 return _cumulatedHistogramPopulation.back();
663 return UInt64Vector(_histogramPopulation.begin() + _inBoundsBinOffset,
664 _histogramPopulation.begin() + _nbClasses);
673 return _firstHistoValue + (
static_cast<ipReal64>(binIdx) - _inBoundsBinOffset) * _binWidth;
682 if (binIdx > _inBoundsBinOffset && (binIdx-_inBoundsBinOffset) == _nbClasses-1)
683 return (_firstHistoValue + (static_cast<ipReal64>(binIdx) - _inBoundsBinOffset) * _binWidth + _lastHistoValue) / 2;
685 return _firstHistoValue + (
static_cast<ipReal64>(binIdx) - _inBoundsBinOffset + 0.5) * _binWidth;
694 if (binIdx > _inBoundsBinOffset && (binIdx-_inBoundsBinOffset) == _nbClasses-1)
695 return _lastHistoValue;
697 return _firstHistoValue + (
static_cast<ipReal64>(binIdx) - _inBoundsBinOffset + 1) * _binWidth;
706 return _firstHistoValue + classIdx * _binWidth;
715 if (classIdx == _nbClasses-1)
716 return (_firstHistoValue + classIdx * _binWidth + _lastHistoValue) / 2;
718 return _firstHistoValue + (classIdx + 0.5) * _binWidth;
727 if (classIdx == _nbClasses-1)
728 return _lastHistoValue;
730 return _firstHistoValue + (classIdx + 1) * _binWidth;
739 return _histogramPopulation[classIdx + _inBoundsBinOffset];
748 return static_cast<ipReal64>(_histogramPopulation[classIdx + _inBoundsBinOffset]) /
759 updateCumulatedIfNeeded();
761 return _cumulatedHistogramPopulation[classIdx + _inBoundsBinOffset];
771 updateCumulatedIfNeeded();
773 return static_cast<ipReal64>(_cumulatedHistogramPopulation[classIdx + _inBoundsBinOffset]) /
783 return value < _firstHistoValue || value > _lastHistoValue;
818 return retrieveBinIdx(value);
826 return _histogramPopulation[binIdx];
837 return static_cast<ipReal64>(_histogramPopulation[binIdx]) /
847 updateCumulatedIfNeeded();
852 return _cumulatedHistogramPopulation[binIdx];
861 updateCumulatedIfNeeded();
866 return static_cast<ipReal64>(_cumulatedHistogramPopulation[binIdx]) /
887 return cumulatedFrequencies;
894 const ipUInt32 binIdx = retrieveBinIdx(value);
897 _histogramPopulation[binIdx] += 1;
904 IPSDK_FORCEINLINE
void 907 _cumulatedHistogramPopulation.clear();
911 BaseHistogram::retrieveBinIdx(
const ipReal64 value)
const 914 if (value < _firstHistoValue)
915 return _lowerOutOfBoundsBinIdx;
918 if (value > _lastHistoValue)
919 return _upperOutOfBoundsBinIdx;
922 const ipReal64 offset = value - _firstHistoValue;
924 if (binIdx == _nbClasses)
927 return binIdx + _inBoundsBinOffset;
930 IPSDK_FORCEINLINE
void 931 BaseHistogram::updateCumulatedIfNeeded()
const 937 if (_cumulatedHistogramPopulation.empty() ==
true)
947 #pragma warning (pop) 949 #endif // __IPSDKMATH_BASEHISTOGRAM_H__ UInt64Vector getHistogramClassPopulation() const
retrieve sub part of collection associated to classes (ie. excluding reserved bin associated to out o...
Definition: BaseHistogram.h:658
Definition of import/export macro for library.
ipReal64 getCumulatedFrequency(const ipReal64 value) const
retrieve histogram cumulated frequency for a given value
Definition: BaseHistogram.h:858
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
ipReal64 getBinEndValue(const ipUInt32 binIdx) const
retrieve ending value for a given histogram bin
Definition: BaseHistogram.h:689
void checkBinIdx(const ipUInt32 classIdx) const
method allowing to check validity of a bin index
ipUInt64 getClassPopulation(const ipUInt32 classIdx) const
access to population for a given class index
Definition: BaseHistogram.h:734
std::vector< ipUInt32 > UInt32Vector
stl vector collections
Definition: BaseCollections.h:33
void checkClassIdx(const ipUInt32 classIdx) const
method allowing to check validity of a class index
void clearCumulatedData()
clear of cumulated data associated to histogram
Definition: BaseHistogram.h:905
Extremal border values are keeped on output.
Definition: ExtremaTypes.h:47
ipReal64 getUpperBound() const
retrieve upper bound for histogram
Definition: BaseHistogram.h:571
ipBool canBeAggregated(const ipReal64 value) const
method allowing to check whether a value can be aggregated to histogram data regards to histogram ran...
Definition: BaseHistogram.h:799
virtual ipBool areDataIntegral() const =0
check whether histogram data are integral
std::vector< ipReal64 > Real64Vector
stl vector collections
Definition: BaseCollections.h:37
std::vector< HistogramExtrema > HistogramExtremaColl
collection of histogram extrema
Definition: HistogramTypes.h:80
ipUInt64 getPopulation(const ipReal64 value) const
retrieve histogram population for a given value
Definition: BaseHistogram.h:822
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
ipReal64 getClassMidValue(const ipUInt32 classIdx) const
retrieve mid value for a given histogram class
Definition: BaseHistogram.h:710
ipReal64 getClassStartValue(const ipUInt32 classIdx) const
retrieve starting value for a given histogram class
Definition: BaseHistogram.h:701
Basic statistical functions.
ipUInt32 getUpperOutOfBoundsBinIdx() const
retrieve bin index associated to upper out of bounds data
Definition: BaseHistogram.h:622
ipReal64 getFirstValue() const
retrieve first value for histogram
Definition: BaseHistogram.h:547
ipUInt64 getClassCumulatedPopulation(const ipUInt32 classIdx) const
access to cumulated population for a given class index
Definition: BaseHistogram.h:753
std::vector< ipUInt64 > UInt64Vector
stl vector collections
Definition: BaseCollections.h:35
Utility functions used during parameter estimation.
ipReal64 getBinMidValue(const ipUInt32 binIdx) const
retrieve mid value for a given histogram bin
Definition: BaseHistogram.h:677
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Definition: KernelKMeansClusteringConfig.h:29
ipReal64 getLowerBound() const
retrieve lower bound for histogram
Definition: BaseHistogram.h:565
Definition: NumericLimits.h:27
boost::shared_ptr< KMeansClustering > KMeansClusteringPtr
shared pointer to KMeansClustering class
Definition: ClusteringTypes.h:96
#define IPSDK_DECLARE_ABSTRACT_SERIAL_WITH_COPY(libraryName, className)
macro enabling serialization on abstract class
Definition: SerializationHdrMacro.h:91
ipBool insertDataInternal(const ipReal64 value)
insertion of data into histogram
Definition: BaseHistogram.h:891
ipReal64 getRange() const
retrieve range for histogram
Definition: BaseHistogram.h:580
ipBool isOutOfBounds(const ipReal64 value) const
method allowing to check whether a given input value is out of histogram bounds
Definition: BaseHistogram.h:778
Definition: KMeansClusteringConfig.h:28
ipReal64 getBinWidth() const
retrieve bin width associated to histogram
Definition: BaseHistogram.h:586
Base class for histogram data management.
Definition: BaseHistogram.h:40
ipUInt32 getLowerOutOfBoundsBinIdx() const
retrieve bin index associated to lower out of bounds data
Definition: BaseHistogram.h:613
std::vector< Vector > VectorColl
collection of vectors
Definition: ClusteringTypes.h:31
ipUInt64 getTotalPopulation() const
retrieve total population for histogram
Definition: BaseHistogram.h:649
Real64Vector getFrequencies() const
compute histogram frequencies
Definition: BaseHistogram.h:873
ipReal64 getClassEndValue(const ipUInt32 classIdx) const
retrieve ending value for a given histogram class
Definition: BaseHistogram.h:722
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
const UInt64Vector & getHistogramPopulation() const
access to data collection associated to histogram
Definition: BaseHistogram.h:640
ipReal64 getFrequency(const ipReal64 value) const
retrieve histogram frequency for a given value
Definition: BaseHistogram.h:832
Real64Vector getCumulatedFrequencies() const
compute histogram cumulated frequencies
Definition: BaseHistogram.h:882
Configuration structure used for estimation management.
Definition: EstimationConfig.h:34
bool isInit() const
check whether object has been initialized
Definition: BaseHistogram.h:541
structure allowing to encapsulate gaussian curve fit information
Definition: HistogramTypes.h:100
ipUInt64 getCumulatedPopulation(const ipReal64 value) const
retrieve histogram cumulated population for a given value
Definition: BaseHistogram.h:844
IPSDKMATH_API EstimationConfig createNonRobustConfig()
function allowing to create a non robust estimation configuration
Predefined base collection types for library.
bool ipBool
Base types definition.
Definition: BaseTypes.h:47
Predefined types for histogram management.
ipReal64 getClassCumulatedFrequency(const ipUInt32 classIdx) const
access to cumulated frequency for a given class index
Definition: BaseHistogram.h:765
eHistogramOutOfBoundsPolicy
enumerate use to describe histogram policy used to process out of bounds data
Definition: HistogramTypes.h:37
ipReal64 getClassFrequency(const ipUInt32 classIdx) const
access to frequency for a given class index
Definition: BaseHistogram.h:743
ipUInt32 getBinIdx(const ipReal64 value) const
retrieve histogram bin index associated to a given input value
Definition: BaseHistogram.h:813
void findLocalMaxima(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, std::vector< IndexType > &extremaIdxColl)
function allowing to search for local maxima into a collection of values
Definition: ExtremaUtils.h:136
ipUInt32 getInBoundsBinOffset() const
retrieve index associated to first in bounds data
Definition: BaseHistogram.h:631
ipBool isOutOfLowerBound(const ipReal64 value) const
method allowing to check whether a given input value is lower than histogram lower bound ...
Definition: BaseHistogram.h:787
void findLocalMinima(const std::vector< T > &inputColl, const eExtremaBorderPolicy &extremaBorderPolicy, std::vector< IndexType > &extremaIdxColl)
function allowing to search for local minima into a collection of values
Definition: ExtremaUtils.h:120
ipUInt32 getNbBins() const
retrieve number of bins associated to histogram
Definition: BaseHistogram.h:604
ipBool isOutOfUpperBound(const ipReal64 value) const
method allowing to check whether a given input value is greater than histogram upper bound ...
Definition: BaseHistogram.h:793
Data with values not in [firstHistoValue, lastHistoValue] are ignored.
Definition: HistogramTypes.h:39
ipUInt32 getNbClasses() const
retrieve number of classes associated to histogram
Definition: BaseHistogram.h:595
Base class for serializable class.
Definition: BaseSerializationObject.h:33
eExtremaBorderPolicy
Enumerate allowing to describe border policy used during extrema extraction processing.
Definition: ExtremaTypes.h:45
ipReal64 getBinStartValue(const ipUInt32 binIdx) const
retrieve starting value for a given histogram bin
Definition: BaseHistogram.h:668
ipReal64 getLastValue() const
retrieve last value for histogram
Definition: BaseHistogram.h:556
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53