![]() |
Persistence 1D inc. Reconstruct1D
1.1
Finding extrema in one dimensional data, filtering them by persistence and reconstructing smooth functions
|
Main Matlab-C++ Interface file. More...
#include <matrix.h>
#include <mex.h>
#include <algorithm>
#include <vector>
#include "..\src\persistence1d\persistence1d.hpp"
Go to the source code of this file.
Macros | |
#define | NUM_INPUT_VARIABLES 1 |
#define | NUM_OUTPUT_VARIABLES 5 |
#define | MATLAB_INDEXING true |
#define | NO_FILTERING 0.0 |
Functions | |
bool | MxFloatArrayToFloatVector (const mxArray *input, std::vector< float > &data) |
Fills a given float data vector with values from float mxArray. More... | |
mxArray * | VectorToMxSingleArray (const std::vector< float > data) |
Copies vector<float> data to 1-d MATLAB matrix. More... | |
mxArray * | VectorToMxSingleArray (const std::vector< int > data) |
Copies vector<int> data to 1-d Single-type MATLAB matrix. More... | |
mxArray * | VectorToMxSingleArray (const std::vector< TPairedExtrema > data) |
Creates a 1-d Single-Type MATLAB matrix with the persistence values from a vector of TPairedExtrema. More... | |
mxArray * | ScalarToMxSingleArray (const float data) |
Creates a 1x1 Single Type Matlab matrix from a single float value. More... | |
mxArray * | ScalarToMxSingleArray (const int data) |
bool | CheckInput (const int nOuts, mxArray *outs[], const int nIns, const mxArray *ins[]) |
Validates the following for the input: More... | |
void | WriteVectorToMexOutput (const std::vector< float > data) |
Displays float-vector content in Matlab output window. More... | |
void | WriteInputToVector (const mxArray *inputs[], std::vector< float > &data) |
Assumption - first input argument is a vector of 1-d data,. More... | |
void | mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) |
Main MATLAB interface. More... | |
Main Matlab-C++ Interface file.
Compile with MEX to use as MATLAB interface for Persistence1D class. Tested on 32-bits only, MATLAB 2011b and above.
Usage: [MinIndices MaxIndices Persistence GlobalMinIdx GlobalMinVal] = run_persistence1d(single(data))
Supports input in single format. Output is INT32 and SINGLE.
To see output messages in Matlab, uncomment line 38 before compilation.
[in] | data | A vector of data, sorted according to coordinates. This should contain only data values to be sorted. Assumes the data is one dimensional. |
[out] | MinIndices | Vector of (Matlab compatible) indices of local maxima. |
[out] | MaxIndices | Vector of (Matlab compatible) indices of local minima. |
[out] | Persistence | Vector of persistence of the paired extrema whose indices live in MinIndices and MaxIndices |
[out] | GlobalMinIdx | Index (Matlab compatible) of global minimum. |
[out] | GlobalMinVal | Value of global minimum. |
Definition in file run_persistence1d.cpp.
#define MATLAB_INDEXING true |
Definition at line 35 of file run_persistence1d.cpp.
#define NO_FILTERING 0.0 |
Definition at line 36 of file run_persistence1d.cpp.
#define NUM_INPUT_VARIABLES 1 |
Definition at line 33 of file run_persistence1d.cpp.
#define NUM_OUTPUT_VARIABLES 5 |
Definition at line 34 of file run_persistence1d.cpp.
bool CheckInput | ( | const int | nOuts, |
mxArray * | outs[], | ||
const int | nIns, | ||
const mxArray * | ins[] | ||
) |
Validates the following for the input:
Validates the following for the output:
[in] | nOuts | Number of output variables. |
[in] | outs | Array of pointers to output matrices. |
[in] | nIns | Number of input variables. |
[in] | ins | Array of pointers in input matrices. |
Definition at line 233 of file run_persistence1d.cpp.
void mexFunction | ( | int | nlhs, |
mxArray * | plhs[], | ||
int | nrhs, | ||
const mxArray * | prhs[] | ||
) |
Main MATLAB interface.
[in,out] | nlhs | Number of left hand (output) matrices. |
[in,out] | plhs | Pointers to left hand (output) matrices. |
[in] | nrhs | Number of right hand (input) matrices. |
[in] | prhs | Pointers to right hand (input) matrices. |
Definition at line 63 of file run_persistence1d.cpp.
bool MxFloatArrayToFloatVector | ( | const mxArray * | input, |
std::vector< float > & | data | ||
) |
Fills a given float data vector with values from float mxArray.
Warning - does not check if mxArray format is single.
Definition at line 128 of file run_persistence1d.cpp.
mxArray * ScalarToMxSingleArray | ( | const float | data | ) |
Creates a 1x1 Single Type Matlab matrix from a single float value.
Definition at line 152 of file run_persistence1d.cpp.
mxArray * ScalarToMxSingleArray | ( | const int | data | ) |
Definition at line 160 of file run_persistence1d.cpp.
mxArray * VectorToMxSingleArray | ( | const std::vector< float > | data | ) |
Copies vector<float> data to 1-d MATLAB matrix.
[in] | data | A vector of float to copy. |
Definition at line 170 of file run_persistence1d.cpp.
mxArray * VectorToMxSingleArray | ( | const std::vector< int > | data | ) |
Copies vector<int> data to 1-d Single-type MATLAB matrix.
[in] | data | data to be copied to Matlab. |
Definition at line 188 of file run_persistence1d.cpp.
mxArray * VectorToMxSingleArray | ( | const std::vector< TPairedExtrema > | data | ) |
Creates a 1-d Single-Type MATLAB matrix with the persistence values from a vector of TPairedExtrema.
[in] | data | Vector of paired extrema |
Definition at line 205 of file run_persistence1d.cpp.
void WriteInputToVector | ( | const mxArray * | inputs[], |
std::vector< float > & | data | ||
) |
Assumption - first input argument is a vector of 1-d data,.
Copies the content of mxArray to a vector.
[in] | inputs | Array of MATLAB matrix data, as received by mexFunction (MATLAB entrance point) |
[out] | data | Vector which contain data for Persistence |
Definition at line 293 of file run_persistence1d.cpp.
void WriteVectorToMexOutput | ( | const std::vector< float > | data | ) |
Displays float-vector content in Matlab output window.
[in] | data | Float vector to write |
Definition at line 276 of file run_persistence1d.cpp.