tesseract  4.0.0-1-g2a2b
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 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_ = nullptr;
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  delete[] hist_;
50  length_ = 0;
51  }

◆ ConstructHorizontalCountHist()

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

Definition at line 487 of file devanagari_processing.cpp.

487  {
488  Clear();
489  Numa* counts = pixCountPixelsByRow(pix, nullptr);
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:98

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