Tesseract  3.02
tesseract::CCNonTextDetect Class Reference

#include <ccnontextdetect.h>

Inheritance diagram for tesseract::CCNonTextDetect:
tesseract::BlobGrid tesseract::BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > tesseract::GridBase

List of all members.

Public Member Functions

 CCNonTextDetect (int gridsize, const ICOORD &bleft, const ICOORD &tright)
virtual ~CCNonTextDetect ()
Pix * ComputeNonTextMask (bool debug, Pix *photo_map, TO_BLOCK *blob_block)

Detailed Description

Definition at line 31 of file ccnontextdetect.h.


Constructor & Destructor Documentation

tesseract::CCNonTextDetect::CCNonTextDetect ( int  gridsize,
const ICOORD bleft,
const ICOORD tright 
)

Definition at line 58 of file ccnontextdetect.cpp.

  : BlobGrid(gridsize, bleft, tright),
    max_noise_count_(static_cast<int>(kMaxSmallNeighboursPerPix *
                                      gridsize * gridsize)),
    noise_density_(NULL) {
  // TODO(rays) break max_noise_count_ out into an area-proportional
  // value, as now plus an additive constant for the number of text blobs
  // in the 3x3 neigbourhood - maybe 9.
}
tesseract::CCNonTextDetect::~CCNonTextDetect ( ) [virtual]

Definition at line 69 of file ccnontextdetect.cpp.

                                  {
  delete noise_density_;
}

Member Function Documentation

Pix * tesseract::CCNonTextDetect::ComputeNonTextMask ( bool  debug,
Pix *  photo_map,
TO_BLOCK blob_block 
)

Definition at line 82 of file ccnontextdetect.cpp.

                                                               {
  // Insert the smallest blobs into the grid.
  InsertBlobList(&blob_block->small_blobs);
  InsertBlobList(&blob_block->noise_blobs);
  // Add the medium blobs that don't have a good strokewidth neighbour.
  // Those that do go into good_grid as an antidote to spreading beyond the
  // real reaches of a noise region.
  BlobGrid good_grid(gridsize(), bleft(), tright());
  BLOBNBOX_IT blob_it(&blob_block->blobs);
  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
    BLOBNBOX* blob = blob_it.data();
    double perimeter_area_ratio = blob->cblob()->perimeter() / 4.0;
    perimeter_area_ratio *= perimeter_area_ratio / blob->enclosed_area();
    if (blob->GoodTextBlob() == 0 || perimeter_area_ratio < kMinGoodTextPARatio)
      InsertBBox(true, true, blob);
    else
      good_grid.InsertBBox(true, true, blob);
  }
  noise_density_ = ComputeNoiseDensity(debug, photo_map, &good_grid);
  good_grid.Clear();  // Not needed any more.
  Pix* pix = noise_density_->ThresholdToPix(max_noise_count_);
  if (debug) {
    pixWrite("junknoisemask.png", pix, IFF_PNG);
  }
  ScrollView* win = NULL;
  if (debug) {
    win = MakeWindow(0, 400, "Photo Mask Blobs");
  }
  // Large and medium blobs are not text if they overlap with "a lot" of small
  // blobs.
  MarkAndDeleteNonTextBlobs(&blob_block->large_blobs,
                            kMaxLargeOverlapsWithSmall,
                            win, ScrollView::DARK_GREEN, pix);
  MarkAndDeleteNonTextBlobs(&blob_block->blobs, kMaxMediumOverlapsWithSmall,
                          win, ScrollView::WHITE, pix);
  // Clear the grid of small blobs and insert the medium blobs.
  Clear();
  InsertBlobList(&blob_block->blobs);
  MarkAndDeleteNonTextBlobs(&blob_block->large_blobs,
                            kMaxLargeOverlapsWithMedium,
                            win, ScrollView::DARK_GREEN, pix);
  // Clear again before we start deleting the blobs in the grid.
  Clear();
  MarkAndDeleteNonTextBlobs(&blob_block->noise_blobs, -1,
                            win, ScrollView::CORAL, pix);
  MarkAndDeleteNonTextBlobs(&blob_block->small_blobs, -1,
                            win, ScrollView::GOLDENROD, pix);
  MarkAndDeleteNonTextBlobs(&blob_block->blobs, -1,
                            win, ScrollView::WHITE, pix);
  if (debug) {
    #ifndef GRAPHICS_DISABLED
    win->Update();
    #endif  // GRAPHICS_DISABLED
    pixWrite("junkccphotomask.png", pix, IFF_PNG);
    #ifndef GRAPHICS_DISABLED
    delete win->AwaitEvent(SVET_DESTROY);
    #endif  // GRAPHICS_DISABLED
    delete win;
  }
  return pix;
}

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