All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 26 of file devanagari_processing.h.

Constructor & Destructor Documentation

tesseract::PixelHistogram::PixelHistogram ( )
inline

Definition at line 28 of file devanagari_processing.h.

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

Definition at line 33 of file devanagari_processing.h.

33  {
34  Clear();
35  }

Member Function Documentation

void tesseract::PixelHistogram::Clear ( )
inline

Definition at line 37 of file devanagari_processing.h.

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

Definition at line 489 of file devanagari_processing.cpp.

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

Definition at line 471 of file devanagari_processing.cpp.

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

Definition at line 457 of file devanagari_processing.cpp.

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

Definition at line 44 of file devanagari_processing.h.

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

Definition at line 48 of file devanagari_processing.h.

48  {
49  return length_;
50  }

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