![]() |
Persistence 1D incl. Reconstruct1D
1.3
Finding extrema in one dimensional data, filtering them by persistence and reconstructing smooth functions
|
Use this program to run Persistence1D on data in text files. More...
Go to the source code of this file.
Macros | |
#define | MATLAB "-MATLAB" |
Functions | |
bool | ReadFileToVector (char *filename, vector< float > &data) |
Tries to open the input file and read its contents to a float vector. More... | |
void | WriteExtremaToFile (char *filename, vector< TPairedExtrema > pairs, const int idxGlobalMin) |
Writes indices of extrema features to file, sorted according to their persistence. More... | |
bool | ParseCmdLine (int argc, char *argv[], float &threshold, bool &matlabIndexing) |
Parses user command line. More... | |
int | main (int argc, char *argv[]) |
Main function - reads a file specified as a command line argument. More... | |
Use this program to run Persistence1D on data in text files.
This file contains a sample code for using Persistence1D on data in text files, and can be used to directly run Persistence1D on data in a single text file.
Command line: persistence1d_driver.exe <filename> [threshold] [-MATLAB]
Definition in file persistence1d_driver.cpp.
#define MATLAB "-MATLAB" |
Definition at line 30 of file persistence1d_driver.cpp.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Main function - reads a file specified as a command line argument.
runs persistence, writes the indices of extrema to a file called inputfilename_res.txt.
Overwrites files with the same name.
Input file name is assumed to end with a three letter extension.
Definition at line 76 of file persistence1d_driver.cpp.
bool ParseCmdLine | ( | int | argc, |
char * | argv[], | ||
float & | threshold, | ||
bool & | matlabIndexing | ||
) |
Parses user command line.
Checks if the user set a threshold value or wants MATLAB indexing.
Definition at line 167 of file persistence1d_driver.cpp.
bool ReadFileToVector | ( | char * | filename, |
vector< float > & | data | ||
) |
Tries to open the input file and read its contents to a float vector.
Input is assumed to be formatted as one number per line, in float compatible notation.
Ignores any lines which do not conform to this assumption.
Number of data entries is assumed to be smaller than vector's class maximum size - this is not checked!
[in] | filename | Name of input file with float data. |
[out] | data | Data is written to this vector. |
Definition at line 122 of file persistence1d_driver.cpp.
void WriteExtremaToFile | ( | char * | filename, |
vector< TPairedExtrema > | pairs, | ||
const int | idxGlobalMin | ||
) |
Writes indices of extrema features to file, sorted according to their persistence.
If no features were found, writes an empty file.
Overwrites any existing file with the same name.
[in] | filename | Name of output file. |
[in] | pairs | Pairs of extrema to write. |
[in] | idxGlobalMin | Index of the global minimum. |
Definition at line 146 of file persistence1d_driver.cpp.