Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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)
- Public Member Functions inherited from tesseract::BlobGrid
 BlobGrid (int gridsize, const ICOORD &bleft, const ICOORD &tright)
virtual ~BlobGrid ()
void InsertBlobList (BLOBNBOX_LIST *blobs)
- Public Member Functions inherited from tesseract::BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT >
 BBGrid ()
 BBGrid (int gridsize, const ICOORD &bleft, const ICOORD &tright)
virtual ~BBGrid ()
void Init (int gridsize, const ICOORD &bleft, const ICOORD &tright)
void Clear ()
void ClearGridData (void(*free_method)(BLOBNBOX *))
void InsertBBox (bool h_spread, bool v_spread, BLOBNBOX *bbox)
void InsertPixPtBBox (int left, int bottom, Pix *pix, BLOBNBOX *bbox)
void RemoveBBox (BLOBNBOX *bbox)
bool RectangleEmpty (const TBOX &rect)
IntGridCountCellElements ()
ScrollViewMakeWindow (int x, int y, const char *window_name)
void DisplayBoxes (ScrollView *window)
void AssertNoDuplicates ()
virtual void HandleClick (int x, int y)
- Public Member Functions inherited from tesseract::GridBase
 GridBase ()
 GridBase (int gridsize, const ICOORD &bleft, const ICOORD &tright)
virtual ~GridBase ()
int gridsize () const
int gridwidth () const
int gridheight () const
const ICOORDbleft () const
const ICOORDtright () const
void GridCoords (int x, int y, int *grid_x, int *grid_y) const
void ClipGridCoords (int *x, int *y) const

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 *
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;
#ifndef GRAPHICS_DISABLED
if (debug) {
win = MakeWindow(0, 400, "Photo Mask Blobs");
}
#endif // GRAPHICS_DISABLED
// Large and medium blobs are not text if they overlap with "a lot" of small
// blobs.
MarkAndDeleteNonTextBlobs(&blob_block->large_blobs,
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,
// 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,
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);
delete win;
#endif // GRAPHICS_DISABLED
}
return pix;
}

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