1 #ifndef __NUMERIC_MATCH_TEMPLATE_HPP__ 2 #define __NUMERIC_MATCH_TEMPLATE_HPP__ 15 template<
typename TIter>
16 void matchTemplate1D(TIter start,TIter end,TIter template_start, TIter template_end,
int &pos,
double &best_match,
bool remove_offset=
true)
18 best_match = std::numeric_limits<double>::max();
20 for(
int i=0;;++i,++start)
25 offset = *template_start - *start;
26 TIter temp_start = start;
27 TIter temp_tstart = template_start;
28 for(;temp_tstart != template_end && temp_start != end;++temp_tstart,++temp_start)
29 match += pow((*temp_start) - (*temp_tstart) + offset,2);
32 if(temp_start == end && temp_tstart != template_end)
35 if(match < best_match)
53 std::vector<T>
joinVectors(
const std::vector<T> &v1,
const std::vector<T> &v2,
int pos,
const T &default_value)
58 temp.resize(pos+v2.size());
59 int n = std::min(pos,(
int)v1.size());
60 std::copy(v1.begin(),v1.begin()+n,temp.begin());
64 std::fill(temp.begin()+n,temp.begin()+pos,default_value);
65 std::copy(v2.begin(),v2.end(),temp.begin()+pos);
70 if((
int)v1.size()-pos > (int)v2.size())
72 int n = (int)v1.size()-pos-(int)v2.size();
73 int hole = n-(int)v1.size();
74 temp.resize(temp.size()+n);
78 std::fill(temp.begin()+((int)temp.size()-n),temp.begin()+((int)temp.size()-n+hole),0);
81 std::copy(v1.begin()+((int)v1.size()-n),v1.end(),temp.begin()+((int)temp.size()-n));
void matchTemplate1D(TIter start, TIter end, TIter template_start, TIter template_end, int &pos, double &best_match, bool remove_offset=true)
Definition: MatchTemplate.hpp:16
std::vector< T > joinVectors(const std::vector< T > &v1, const std::vector< T > &v2, int pos, const T &default_value)
Definition: MatchTemplate.hpp:53