tesseract  4.00.00dev
tesseract::PixelHistogram Class Reference

#include <devanagari_processing.h>

Public Member Functions

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

Detailed Description

Definition at line 37 of file devanagari_processing.h.

Constructor & Destructor Documentation

◆ PixelHistogram()

tesseract::PixelHistogram::PixelHistogram ( )
inline

Definition at line 39 of file devanagari_processing.h.

39  {
40  hist_ = NULL;
41  length_ = 0;
42  }

◆ ~PixelHistogram()

tesseract::PixelHistogram::~PixelHistogram ( )
inline

Definition at line 44 of file devanagari_processing.h.

44  {
45  Clear();
46  }

Member Function Documentation

◆ Clear()

void tesseract::PixelHistogram::Clear ( )
inline

Definition at line 48 of file devanagari_processing.h.

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

◆ ConstructHorizontalCountHist()

void tesseract::PixelHistogram::ConstructHorizontalCountHist ( Pix *  pix)

Definition at line 487 of file devanagari_processing.cpp.

487  {
488  Clear();
489  Numa* counts = pixCountPixelsByRow(pix, NULL);
490  length_ = numaGetCount(counts);
491  hist_ = new int[length_];
492  for (int i = 0; i < length_; ++i) {
493  l_int32 val = 0;
494  numaGetIValue(counts, i, &val);
495  hist_[i] = val;
496  }
497  numaDestroy(&counts);
498 }

◆ ConstructVerticalCountHist()

void tesseract::PixelHistogram::ConstructVerticalCountHist ( Pix *  pix)

Definition at line 469 of file devanagari_processing.cpp.

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

◆ GetHistogramMaximum()

int tesseract::PixelHistogram::GetHistogramMaximum ( int count) const

Definition at line 455 of file devanagari_processing.cpp.

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

◆ hist()

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

Definition at line 55 of file devanagari_processing.h.

55 { return hist_; }

◆ length()

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

Definition at line 57 of file devanagari_processing.h.

57  {
58  return length_;
59  }

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