tesseract
3.03
|
Go to the source code of this file.
Classes | |
class | LLSQ |
Functions | |
template<typename T > | |
T | MedianOfCircularValues (T modulus, GenericVector< T > *v) |
T MedianOfCircularValues | ( | T | modulus, |
GenericVector< T > * | v | ||
) |
Definition at line 111 of file linlsq.h.
{ LLSQ stats; T halfrange = static_cast<T>(modulus / 2); int num_elements = v->size(); for (int i = 0; i < num_elements; ++i) { stats.add((*v)[i], (*v)[i] + halfrange); } bool offset_needed = stats.y_variance() < stats.x_variance(); if (offset_needed) { for (int i = 0; i < num_elements; ++i) { (*v)[i] += halfrange; } } int median_index = v->choose_nth_item(num_elements / 2); if (offset_needed) { for (int i = 0; i < num_elements; ++i) { (*v)[i] -= halfrange; } } return (*v)[median_index]; }