MCPcopy Create free account
hub / github.com/creatale/node-dv / ClassifyNormalizeIfNeeded

Method ClassifyNormalizeIfNeeded

deps/tesseract/ccstruct/blobs.cpp:363–383  ·  view source on GitHub ↗

Normalizes the blob for classification only if needed. (Normally this means a non-zero classify rotation.) If no Normalization is needed, then NULL is returned, and the input blob can be used directly. Otherwise a new TBLOB is returned which must be deleted after use.

Source from the content-addressed store, hash-verified

361// can be used directly. Otherwise a new TBLOB is returned which must be
362// deleted after use.
363TBLOB* TBLOB::ClassifyNormalizeIfNeeded() const {
364 TBLOB* rotated_blob = NULL;
365 // If necessary, copy the blob and rotate it. The rotation is always
366 // +/- 90 degrees, as 180 was already taken care of.
367 if (denorm_.block() != NULL &&
368 denorm_.block()->classify_rotation().y() != 0.0) {
369 TBOX box = bounding_box();
370 int x_middle = (box.left() + box.right()) / 2;
371 int y_middle = (box.top() + box.bottom()) / 2;
372 rotated_blob = new TBLOB(*this);
373 const FCOORD& rotation = denorm_.block()->classify_rotation();
374 // Move the rotated blob back to the same y-position so that we
375 // can still distinguish similar glyphs with differeny y-position.
376 float target_y = kBlnBaselineOffset +
377 (rotation.y() > 0 ? x_middle - box.left() : box.right() - x_middle);
378 rotated_blob->Normalize(NULL, &rotation, &denorm_, x_middle, y_middle,
379 1.0f, 1.0f, 0.0f, target_y,
380 denorm_.inverse(), denorm_.pix());
381 }
382 return rotated_blob;
383}
384
385// Copies the data and the outline, but leaves next untouched.
386void TBLOB::CopyFrom(const TBLOB& src) {

Callers 2

LearnPiecesMethod · 0.80
call_matcherMethod · 0.80

Calls 7

classify_rotationMethod · 0.80
pixMethod · 0.80
bounding_boxFunction · 0.70
blockMethod · 0.45
yMethod · 0.45
NormalizeMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected