![]() |
Persistence 1D incl. Reconstruct1D
1.3
Finding extrema in one dimensional data, filtering them by persistence and reconstructing smooth functions
|
Finds extrema and their persistence in one-dimensional data. More...
#include <persistence1d.hpp>
Public Member Functions | |
Persistence1D () | |
~Persistence1D () | |
bool | RunPersistence (const std::vector< float > &InputData) |
Call this function with a vector of one dimensional data to find extrema features in the data. More... | |
void | PrintPairs (const std::vector< TPairedExtrema > &pairs) const |
Prints the contents of the TPairedExtrema vector. More... | |
void | PrintResults (const float threshold=0.0, const bool matlabIndexing=false) const |
Prints the global minimum and all paired extrema whose persistence is greater or equal to threshold. More... | |
bool | GetPairedExtrema (std::vector< TPairedExtrema > &pairs, const float threshold=0, const bool matlabIndexing=false) const |
Use this method to get the results of RunPersistence. More... | |
bool | GetExtremaIndices (std::vector< int > &min, std::vector< int > &max, const float threshold=0, const bool matlabIndexing=false) const |
Use this method to get two vectors with all indices of PairedExterma. More... | |
int | GetGlobalMinimumIndex (const bool matlabIndexing=false) const |
Returns the index of the global minimum. More... | |
float | GetGlobalMinimumValue () const |
Returns the value of the global minimum. More... | |
bool | VerifyResults () |
Runs basic sanity checks on results of RunPersistence: More... | |
Protected Member Functions | |
void | MergeComponents (const int firstIdx, const int secondIdx) |
Merges two components by doing the following: More... | |
void | CreatePairedExtrema (const int firstIdx, const int secondIdx) |
Creates a new PairedExtrema from the two indices, and adds it to PairedFeatures. More... | |
void | CreateComponent (const int minIdx) |
Creates a new component at a local minimum. More... | |
void | ExtendComponent (const int componentIdx, const int dataIdx) |
Extends the component's region by one vertex: More... | |
void | Init () |
Initializes main data structures used in class: More... | |
void | CreateIndexValueVector () |
Creates SortedData vector. More... | |
void | Watershed () |
Main algorithm - all of the work happen here. More... | |
void | SortPairedExtrema () |
Sorts the PairedExtrema list according to the persistence of the features. More... | |
std::vector< TPairedExtrema >::const_iterator | FilterByPersistence (const float threshold=0) const |
Returns an iterator to the first element in PairedExtrema whose persistence is bigger or equal to threshold. More... | |
bool | VerifyAliveComponents () |
Runs at the end of RunPersistence, after Watershed. More... | |
Protected Attributes | |
std::vector< float > | Data |
Contain a copy of the original input data. More... | |
std::vector< TIdxAndData > | SortedData |
Contains a copy the value and index pairs of Data, sorted according to the data values. More... | |
std::vector< int > | Colors |
Contains the Component assignment for each vertex in Data. More... | |
std::vector< TComponent > | Components |
A vector of Components. More... | |
std::vector< TPairedExtrema > | PairedExtrema |
A vector of paired extrema features - always a minimum and a maximum. More... | |
unsigned int | TotalComponents |
bool | AliveComponentsVerified |
Finds extrema and their persistence in one-dimensional data.
Local minima and local maxima are extracted, paired, and sorted according to their persistence. The global minimum is extracted as well.
We assume a connected one-dimensional domain. Think of "data on a line", or a function f(x) over some domain xmin <= x <= xmax.
Definition at line 106 of file persistence1d.hpp.
|
inline |
Definition at line 109 of file persistence1d.hpp.
|
inline |
Definition at line 113 of file persistence1d.hpp.
|
inlineprotected |
Creates a new component at a local minimum.
Neighboring vertices are assumed to have no color.
[in] | minIdx | Index of a local minimum. |
Definition at line 491 of file persistence1d.hpp.
|
inlineprotected |
Creates SortedData vector.
Assumes Data is already set.
Definition at line 583 of file persistence1d.hpp.
|
inlineprotected |
Creates a new PairedExtrema from the two indices, and adds it to PairedFeatures.
[in] | firstIdx,secondIdx | Indices of vertices to be paired. Order does not matter. |
Definition at line 438 of file persistence1d.hpp.
|
inlineprotected |
Extends the component's region by one vertex:
[in] | componentIdx | Index of component (the value of a neighboring vertex in Colors[]). |
[in] | dataIdx | Index of vertex which the component is extended to. |
Definition at line 521 of file persistence1d.hpp.
|
inlineprotected |
Returns an iterator to the first element in PairedExtrema whose persistence is bigger or equal to threshold.
If threshold is set to 0, returns an iterator to the first object in PairedExtrema.
[in] | threshold | Minimum persistence of features to be returned. |
Definition at line 705 of file persistence1d.hpp.
|
inline |
Use this method to get two vectors with all indices of PairedExterma.
Returns false if no paired features were found. Returned vectors have the same length. Overwrites any data contained in min, max vectors.
[out] | min | Vector of indices of paired local minima. |
[out] | max | Vector of indices of paired local maxima. |
[in] | threshold | Return only indices for pairs whose persistence is greater than or equal to threshold. |
[in] | matlabIndexing | Set this to true to change all indices to match Matlab's 1-indexing. |
Definition at line 241 of file persistence1d.hpp.
|
inline |
Returns the index of the global minimum.
The global minimum does not get paired and is not returned via GetPairedExtrema and GetExtremaIndices.
Definition at line 269 of file persistence1d.hpp.
|
inline |
Returns the value of the global minimum.
The global minimum does not get paired and is not returned via GetPairedExtrema and GetExtremaIndices.
Definition at line 287 of file persistence1d.hpp.
|
inline |
Use this method to get the results of RunPersistence.
Returned pairs are sorted according to persistence, from least to most persistent.
[out] | pairs | Destination vector for PairedExtrema |
[in] | threshold | Minimal persistence value of returned features. All PairedExtrema with persistence equal to or above this value will be returned. If left to default, all PairedMaxima will be returned. |
[in] | matlabIndexing | Set this to true to change all indices of features to Matlab's 1-indexing. |
Definition at line 206 of file persistence1d.hpp.
|
inlineprotected |
Initializes main data structures used in class:
Note: SortedData is should be created before, separately, using CreateIndexValueVector()
Definition at line 557 of file persistence1d.hpp.
|
inlineprotected |
Merges two components by doing the following:
[in] | firstIdx,secondIdx | Indices of components to be merged. Their order does not matter. |
Definition at line 389 of file persistence1d.hpp.
|
inline |
Prints the contents of the TPairedExtrema vector.
If called directly with a TPairedExtrema vector, the global minimum is not printed.
[in] | pairs | Vector of pairs to be printed. |
Definition at line 153 of file persistence1d.hpp.
|
inline |
Prints the global minimum and all paired extrema whose persistence is greater or equal to threshold.
By default, all pairs are printed. Supports Matlab indexing.
[in] | threshold | Threshold value for pair persistence. |
[in] | matlabIndexing | Use Matlab indexing for printing. |
Definition at line 172 of file persistence1d.hpp.
|
inline |
Call this function with a vector of one dimensional data to find extrema features in the data.
The function runs once for, results can be retrieved with different persistent thresholds without further data processing.
Input data vector is assumed to be of legal size and legal values.
Use PrintResults, GetPairedExtrema or GetExtremaIndices to get results of the function.
[in] | InputData | Vector of data to find features on, ordered according to its axis. |
Definition at line 128 of file persistence1d.hpp.
|
inlineprotected |
Sorts the PairedExtrema list according to the persistence of the features.
Orders features with equal persistence according the the index of their minima.
Definition at line 693 of file persistence1d.hpp.
|
inlineprotected |
Runs at the end of RunPersistence, after Watershed.
Algorithm results should be as followed:
Definition at line 722 of file persistence1d.hpp.
|
inline |
Runs basic sanity checks on results of RunPersistence:
Returns true if run results pass these sanity checks.
Definition at line 304 of file persistence1d.hpp.
|
inlineprotected |
Main algorithm - all of the work happen here.
Use only after calling CreateIndexValueVector and Init functions.
Iterates over each vertex in the graph according to their ordered values:
Definition at line 612 of file persistence1d.hpp.
|
protected |
Definition at line 377 of file persistence1d.hpp.
|
protected |
Contains the Component assignment for each vertex in Data.
Only edges of destroyed components are updated to the new component color. The Component values in this vector are invalid at the end of the algorithm.
Definition at line 360 of file persistence1d.hpp.
|
protected |
A vector of Components.
The component index within the vector is used as its Colors in the Watershed function.
Definition at line 367 of file persistence1d.hpp.
|
protected |
Contain a copy of the original input data.
Definition at line 346 of file persistence1d.hpp.
|
protected |
A vector of paired extrema features - always a minimum and a maximum.
Definition at line 373 of file persistence1d.hpp.
|
protected |
Contains a copy the value and index pairs of Data, sorted according to the data values.
Definition at line 352 of file persistence1d.hpp.
|
protected |
Definition at line 376 of file persistence1d.hpp.