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

Function jbClassifyCorrelation

deps/leptonica/src/jbclass.c:1029–1294  ·  view source on GitHub ↗

----------------------------------------------------------------------* * Classification using windowed correlation score * *----------------------------------------------------------------------*/ ! * \brief jbClassifyCorrelation() * * \param[in] jbclasser * \param[in] boxa of new components for classification * \param[in] pixas of new components for classif

Source from the content-addressed store, hash-verified

1027 * \return 0 if OK; 1 on error
1028 */
1029l_int32
1030jbClassifyCorrelation(JBCLASSER *classer,
1031 BOXA *boxa,
1032 PIXA *pixas)
1033{
1034l_int32 n, nt, i, iclass, wt, ht, found, area, area1, area2, npages,
1035 overthreshold;
1036l_int32 *sumtab, *centtab;
1037l_uint32 *row, word;
1038l_float32 x1, y1, x2, y2, xsum, ysum;
1039l_float32 thresh, weight, threshold;
1040BOX *box;
1041NUMA *naclass, *napage;
1042NUMA *nafgt; /* fg area of all templates */
1043NUMA *naarea; /* w * h area of all templates */
1044JBFINDCTX *findcontext;
1045L_DNAHASH *dahash;
1046PIX *pix, *pix1, *pix2;
1047PIXA *pixa, *pixa1, *pixat;
1048PIXAA *pixaa;
1049PTA *pta, *ptac, *ptact;
1050l_int32 *pixcts; /* pixel counts of each pixa */
1051l_int32 **pixrowcts; /* row-by-row pixel counts of each pixa */
1052l_int32 x, y, rowcount, downcount, wpl;
1053l_uint8 byte;
1054
1055 PROCNAME("jbClassifyCorrelation");
1056
1057 if (!classer)
1058 return ERROR_INT("classer not found", procName, 1);
1059 if (!boxa)
1060 return ERROR_INT("boxa not found", procName, 1);
1061 if (!pixas)
1062 return ERROR_INT("pixas not found", procName, 1);
1063
1064 npages = classer->npages;
1065
1066 /* Generate the bordered pixa, which contains all the the
1067 * input components. This will not be saved. */
1068 if ((n = pixaGetCount(pixas)) == 0) {
1069 L_WARNING("pixas is empty\n", procName);
1070 return 0;
1071 }
1072 pixa1 = pixaCreate(n);
1073 for (i = 0; i < n; i++) {
1074 pix = pixaGetPix(pixas, i, L_CLONE);
1075 pix1 = pixAddBorderGeneral(pix, JB_ADDED_PIXELS, JB_ADDED_PIXELS,
1076 JB_ADDED_PIXELS, JB_ADDED_PIXELS, 0);
1077 pixaAddPix(pixa1, pix1, L_INSERT);
1078 pixDestroy(&pix);
1079 }
1080
1081 /* Use these to save the class and page of each component. */
1082 naclass = classer->naclass;
1083 napage = classer->napage;
1084
1085 /* Get the number of fg pixels in each component. */
1086 nafgt = classer->nafgt; /* holds fg areas of the templates */

Callers 1

jbAddPageComponentsFunction · 0.85

Calls 15

pixaGetCountFunction · 0.85
pixaCreateFunction · 0.85
pixaGetPixFunction · 0.85
pixAddBorderGeneralFunction · 0.85
pixaAddPixFunction · 0.85
pixDestroyFunction · 0.85
makePixelSumTab8Function · 0.85
makePixelCentroidTab8Function · 0.85
ptaCreateFunction · 0.85
pixGetHeightFunction · 0.85
pixGetWplFunction · 0.85
pixGetDataFunction · 0.85

Tested by

no test coverage detected