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

Function pixSearchForRectangle

deps/leptonica/src/boxfunc3.c:1057–1281  ·  view source on GitHub ↗

! * \brief pixSearchForRectangle() * * \param[in] pixs 1 bpp * \param[in] boxs current region to investigate * \param[in] minsum minimum pixels to trigger propagation * \param[in] skipdist distance before computing sum for propagation * \param[in] delta difference required to stop propagation * \param[in] maxbg maximum number of allowed bg pixels in ref scan * \param[

Source from the content-addressed store, hash-verified

1055 * </pre>
1056 */
1057static l_int32
1058pixSearchForRectangle(PIX *pixs,
1059 BOX *boxs,
1060 l_int32 minsum,
1061 l_int32 skipdist,
1062 l_int32 delta,
1063 l_int32 maxbg,
1064 l_int32 sideflag,
1065 BOXA *boxat,
1066 NUMA *nascore)
1067{
1068l_int32 bx, by, bw, bh, width, height, setref, atref;
1069l_int32 minincol, maxincol, mininrow, maxinrow, minval, maxval, bgref;
1070l_int32 x, y, x0, y0, xref, yref, colsum, rowsum, score, countref, diff;
1071void **lines1;
1072BOX *boxr;
1073
1074 PROCNAME("pixSearchForRectangle");
1075
1076 if (!pixs || pixGetDepth(pixs) != 1)
1077 return ERROR_INT("pixs undefined or not 1 bpp", procName, 1);
1078 if (!boxs)
1079 return ERROR_INT("boxs not defined", procName, 1);
1080 if (!boxat)
1081 return ERROR_INT("boxat not defined", procName, 1);
1082 if (!nascore)
1083 return ERROR_INT("nascore not defined", procName, 1);
1084
1085 lines1 = pixGetLinePtrs(pixs, NULL);
1086 boxGetGeometry(boxs, &bx, &by, &bw, &bh);
1087 boxr = NULL;
1088 setref = 0;
1089 atref = 0;
1090 maxval = 0;
1091 minval = 100000;
1092 score = 0; /* sum of all (fg - bg) pixels seen in the scan */
1093 xref = yref = 100000; /* init to impossibly big number */
1094 if (sideflag == L_FROM_LEFT) {
1095 for (x = bx; x < bx + bw; x++) {
1096 colsum = 0;
1097 maxincol = 0;
1098 minincol = 100000;
1099 for (y = by; y < by + bh; y++) {
1100 if (GET_DATA_BIT(lines1[y], x)) {
1101 colsum++;
1102 if (y > maxincol) maxincol = y;
1103 if (y < minincol) minincol = y;
1104 }
1105 }
1106 score += colsum;
1107
1108 /* Enough fg to sweep out a rectangle? */
1109 if (!setref && colsum >= minsum) {
1110 setref = 1;
1111 xref = x + 10;
1112 if (xref >= bx + bw)
1113 goto failure;
1114 }

Callers 1

Calls 6

pixGetDepthFunction · 0.85
pixGetLinePtrsFunction · 0.85
boxGetGeometryFunction · 0.85
boxCreateFunction · 0.85
numaAddNumberFunction · 0.85
boxaAddBoxFunction · 0.85

Tested by

no test coverage detected