tesseract  3.05.02
tesseract::PixelHistogram Class Reference

#include <devanagari_processing.h>

Public Member Functions

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

Detailed Description

Definition at line 35 of file devanagari_processing.h.

Constructor & Destructor Documentation

◆ PixelHistogram()

tesseract::PixelHistogram::PixelHistogram ( )
inline

Definition at line 37 of file devanagari_processing.h.

37  {
38  hist_ = NULL;
39  length_ = 0;
40  }

◆ ~PixelHistogram()

tesseract::PixelHistogram::~PixelHistogram ( )
inline

Definition at line 42 of file devanagari_processing.h.

42  {
43  Clear();
44  }

Member Function Documentation

◆ Clear()

void tesseract::PixelHistogram::Clear ( )
inline

Definition at line 46 of file devanagari_processing.h.

46  {
47  if (hist_) {
48  delete[] hist_;
49  }
50  length_ = 0;
51  }

◆ ConstructHorizontalCountHist()

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 }

◆ ConstructVerticalCountHist()

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 }

◆ GetHistogramMaximum()

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:103

◆ hist()

int* tesseract::PixelHistogram::hist ( ) const
inline

Definition at line 53 of file devanagari_processing.h.

53 { return hist_; }

◆ length()

int tesseract::PixelHistogram::length ( ) const
inline

Definition at line 55 of file devanagari_processing.h.

55  {
56  return length_;
57  }

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