----------------------------------------------------------------------* * 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
| 1027 | * \return 0 if OK; 1 on error |
| 1028 | */ |
| 1029 | l_int32 |
| 1030 | jbClassifyCorrelation(JBCLASSER *classer, |
| 1031 | BOXA *boxa, |
| 1032 | PIXA *pixas) |
| 1033 | { |
| 1034 | l_int32 n, nt, i, iclass, wt, ht, found, area, area1, area2, npages, |
| 1035 | overthreshold; |
| 1036 | l_int32 *sumtab, *centtab; |
| 1037 | l_uint32 *row, word; |
| 1038 | l_float32 x1, y1, x2, y2, xsum, ysum; |
| 1039 | l_float32 thresh, weight, threshold; |
| 1040 | BOX *box; |
| 1041 | NUMA *naclass, *napage; |
| 1042 | NUMA *nafgt; /* fg area of all templates */ |
| 1043 | NUMA *naarea; /* w * h area of all templates */ |
| 1044 | JBFINDCTX *findcontext; |
| 1045 | L_DNAHASH *dahash; |
| 1046 | PIX *pix, *pix1, *pix2; |
| 1047 | PIXA *pixa, *pixa1, *pixat; |
| 1048 | PIXAA *pixaa; |
| 1049 | PTA *pta, *ptac, *ptact; |
| 1050 | l_int32 *pixcts; /* pixel counts of each pixa */ |
| 1051 | l_int32 **pixrowcts; /* row-by-row pixel counts of each pixa */ |
| 1052 | l_int32 x, y, rowcount, downcount, wpl; |
| 1053 | l_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 */ |
no test coverage detected