tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccstruct/linlsq.h File Reference
#include "points.h"
#include "params.h"

Go to the source code of this file.

Classes

class  LLSQ

Functions

template<typename T >
MedianOfCircularValues (T modulus, GenericVector< T > *v)

Function Documentation

template<typename T >
T MedianOfCircularValues ( 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];
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines