const vector<int> Index::createUMax() { int patchSize = ROTATION_PATCH_SIZE; // Make sure we forget about what is too close to the boundary //edge_threshold_ = std::max(edge_threshold_, patch_size_/2 + kKernelWidth / 2 + 2); // pre-compute the end of a row in a circular patch int halfPatchSize = patchSize / 2; vector<int> u_max(halfPatchSize + 2); int v, v0, vmax = cvFloor(halfPatchSize * sqrt(2.f) / 2 + 1); int vmin = cvCeil(halfPatchSize * sqrt(2.f) / 2); for (v = 0; v <= vmax; ++v) u_max[v] = cvRound(sqrt((double)halfPatchSize * halfPatchSize - v * v)); // Make sure we are symmetric for (v = halfPatchSize, v0 = 0; v >= vmin; --v) { while (u_max[v0] == u_max[v0 + 1]) ++v0; u_max[v] = v0; ++v0; } return u_max; }
double relative_difference(double a, double b) { double c = u_abs(a); double d = u_abs(b); d = u_max(c, d); return d == 0.0 ? 0.0 : u_abs(a - b) / d; }