예제 #1
0
/**************************************************************************//**
 * @author Hannah Aker, Zachary Pierson, Steven Huerta
 *
 * @par Description:
 * decomp - Finds interesting transformation spaces by continually dividing
 * up the transformation space, evaluating for possible matches, and
 * dividing again until no further division is possible
 *
 * @param[in,out] target - Image_Model of the target
 * @param[in,out] model - Image_Model of the model
 * @param[in,out] pixelErrorThresh - pixel threshold for maximum distance
 * @param[in,out] percentList - percent of list of distances to evaluate
 * @param[in,out] alpha - contols skew factor - NOT IMPLEMENTED
 *
 * @returns vector<double> list of transformations as tsObjects
 *
 *****************************************************************************/
vector<tsObject> decomp(Image_Model& target, Image_Model& model,
                        float pixelErrorThresh = 1, float percentList = 1.0,
                        int alpha = 1)
{
    cout << "Decomp!" << endl;
    // initialize a list of container for tsObjects
    vector<tsObject> realMatches;

    // initialize our first transformation space paramaters
    tsObject tsObj(0, target.cols - model.cols, 0, target.rows - model.rows,1,1,1,1);

    // get our distance of possible transforms in the transform space
    double gamma = calcGamma(tsObj, model.cols-1, model.rows-1);

    queue<tsObject> matches;
    matches.push(tsObj);

    //while (!matches.size()!=0)
    while (!matches.empty())
    {
        gamma = calcGamma(matches.front(), model.cols-1, model.rows-1);
        //cout << "Gamma is " << gamma << endl;
        int thresh = pixelErrorThresh + gamma;
        if ( isInteresting( matches.front(), target, model, percentList, thresh ) )
        {
            if(gamma < 1.5)
            {
                realMatches.push_back(matches.front());
                //printf("realMatches\n");
            }
            else
            {

                vector<tsObject> addMatches = divide(matches.front());
                while( addMatches.size()!= 0)
                {
                    matches.push(addMatches.back());
                    addMatches.pop_back();
                }
            }

            //vector<tsObject> divided = divide(matches.front());
            //matches.insert( matches.end(), divided.begin(), divided.end() ) ;

        }
        //matches.erase( matches.begin() ) ;
        matches.pop();
    }
    cout << "Finished Decomp!!" << endl;
    return realMatches;
}
예제 #2
0
파일: Distance.cpp 프로젝트: fand/gdust
double
Distance::DTW(const TimeSeries &ts1, const TimeSeries &ts2) {
  int len1 = ts1.length();
  int len2 = ts2.length();

  double *table_d = new double[len1 * len2];
  double *table_g = new double[len1 * len2];

  calcCost(ts1, ts2, table_d, table_g, len1, len2);
  calcGamma(table_d, table_g, len1, len2);
  double dist = calcSum(table_d, table_g, len1, len2);

  delete[] table_d;
  delete[] table_g;
  return dist;
}