|
tesseract 3.04.01
|
#include <ccnontextdetect.h>
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) |
Definition at line 31 of file ccnontextdetect.h.
| tesseract::CCNonTextDetect::CCNonTextDetect | ( | int | gridsize, |
| const ICOORD & | bleft, | ||
| const ICOORD & | tright | ||
| ) |
Definition at line 65 of file ccnontextdetect.cpp.
{
// 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 neighbourhood - maybe 9.
}
CCNonTextDetect::~CCNonTextDetect() {
delete noise_density_;
| tesseract::CCNonTextDetect::~CCNonTextDetect | ( | ) | [virtual] |
Definition at line 76 of file ccnontextdetect.cpp.
| Pix * tesseract::CCNonTextDetect::ComputeNonTextMask | ( | bool | debug, |
| Pix * | photo_map, | ||
| TO_BLOCK * | blob_block | ||
| ) |
Definition at line 89 of file ccnontextdetect.cpp.
{
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,
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);
delete win;
#endif // GRAPHICS_DISABLED
}
return pix;
}
// Computes and returns the noise_density IntGrid, at the same gridsize as
// this by summing the number of small elements in a 3x3 neighbourhood of