Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tesseract::PixelHistogram Class Reference

#include <devanagari_processing.h>

Public Member Functions

 PixelHistogram ()
 
 ~PixelHistogram ()
 
void Clear ()
 
int *const hist () const
 
int length () const
 
void ConstructVerticalCountHist (Pix *pix)
 
void ConstructHorizontalCountHist (Pix *pix)
 
int GetHistogramMaximum (int *count) const
 

Detailed Description

Definition at line 27 of file devanagari_processing.h.

Constructor & Destructor Documentation

tesseract::PixelHistogram::PixelHistogram ( )
inline

Definition at line 29 of file devanagari_processing.h.

29  {
30  hist_ = NULL;
31  length_ = 0;
32  }
#define NULL
Definition: host.h:144
tesseract::PixelHistogram::~PixelHistogram ( )
inline

Definition at line 34 of file devanagari_processing.h.

34  {
35  Clear();
36  }

Member Function Documentation

void tesseract::PixelHistogram::Clear ( )
inline

Definition at line 38 of file devanagari_processing.h.

38  {
39  if (hist_) {
40  delete[] hist_;
41  }
42  length_ = 0;
43  }
void tesseract::PixelHistogram::ConstructHorizontalCountHist ( Pix *  pix)

Definition at line 486 of file devanagari_processing.cpp.

486  {
487  Clear();
488  Numa* counts = pixCountPixelsByRow(pix, NULL);
489  length_ = numaGetCount(counts);
490  hist_ = new int[length_];
491  for (int i = 0; i < length_; ++i) {
492  l_int32 val = 0;
493  numaGetIValue(counts, i, &val);
494  hist_[i] = val;
495  }
496  numaDestroy(&counts);
497 }
#define NULL
Definition: host.h:144
void tesseract::PixelHistogram::ConstructVerticalCountHist ( Pix *  pix)

Definition at line 468 of file devanagari_processing.cpp.

468  {
469  Clear();
470  int width = pixGetWidth(pix);
471  int height = pixGetHeight(pix);
472  hist_ = new int[width];
473  length_ = width;
474  int wpl = pixGetWpl(pix);
475  l_uint32 *data = pixGetData(pix);
476  for (int i = 0; i < width; ++i)
477  hist_[i] = 0;
478  for (int i = 0; i < height; ++i) {
479  l_uint32 *line = data + i * wpl;
480  for (int j = 0; j < width; ++j)
481  if (GET_DATA_BIT(line, j))
482  ++(hist_[j]);
483  }
484 }
int tesseract::PixelHistogram::GetHistogramMaximum ( int *  count) const

Definition at line 454 of file devanagari_processing.cpp.

454  {
455  int best_value = 0;
456  for (int i = 0; i < length_; ++i) {
457  if (hist_[i] > hist_[best_value]) {
458  best_value = i;
459  }
460  }
461  if (count) {
462  *count = hist_[best_value];
463  }
464  return best_value;
465 }
int count(LIST var_list)
Definition: oldlist.cpp:108
int* const tesseract::PixelHistogram::hist ( ) const
inline

Definition at line 45 of file devanagari_processing.h.

45  {
46  return hist_;
47  }
int tesseract::PixelHistogram::length ( ) const
inline

Definition at line 49 of file devanagari_processing.h.

49  {
50  return length_;
51  }

The documentation for this class was generated from the following files: