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

Function EvaluateHorizontalDiff

deps/tesseract/ccstruct/coutln.cpp:709–725  ·  view source on GitHub ↗

* Helper evaluates a horizontal difference, (x,y) - (x-1,y), where y is implied * by the input image line, returning true if the difference matches diff_sign * and updating the best_diff, best_sum, best_x if a new max. */

Source from the content-addressed store, hash-verified

707 * and updating the best_diff, best_sum, best_x if a new max.
708 */
709static bool EvaluateHorizontalDiff(const l_uint32* line, int diff_sign,
710 int x, int width,
711 int* best_diff, int* best_sum, int* best_x) {
712 if (x <= 0 || x >= width)
713 return false;
714 int pixel1 = GET_DATA_BYTE(
715 const_cast<void*>(reinterpret_cast<const void*>(line)), x - 1);
716 int pixel2 =
717 GET_DATA_BYTE(const_cast<void*>(reinterpret_cast<const void*>(line)), x);
718 int diff = (pixel2 - pixel1) * diff_sign;
719 if (diff > *best_diff) {
720 *best_diff = diff;
721 *best_sum = pixel1 + pixel2;
722 *best_x = x;
723 }
724 return diff > 0;
725}
726
727/**
728 * Adds sub-pixel resolution EdgeOffsets for the outline if the supplied

Callers 1

ComputeEdgeOffsetsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected