42 #include <config_auto.h>
45 #include "allheaders.h"
48 static BOXA *pixLocateStaveSets(
PIX *pixs, l_int32 pageno,
PIXA *pixadb);
49 static l_ok boxaRemoveVGaps(
BOXA *boxa);
79 const char *debugfile)
85 return ERROR_INT(
"dirname not defined", __func__, 1);
86 if (nparts < 0 || nparts > 10)
87 return ERROR_INT(
"nparts not in [1 ... 10]", __func__, 1);
88 if (!outroot || outroot[0] ==
'\n')
89 return ERROR_INT(
"outroot undefined or empty", __func__, 1);
95 L_INFO(
"writing debug output to %s\n", __func__, debugfile);
97 "Partify Debug", debugfile);
127 l_int32 i, j, pageno, res, npage, nbox, icount, line;
131 BOXA *boxa1, *boxa2, *boxa3;
132 PIX *pix1, *pix2, *pix3, *pix4, *pix5;
136 return ERROR_INT(
"pixac not defined", __func__, 1);
138 return ERROR_INT(
"pixac is empty", __func__, 1);
139 if (nparts < 1 || nparts > 10)
140 return ERROR_INT(
"nparts not in [1 ... 10]", __func__, 1);
141 if (!outroot || outroot[0] ==
'\n')
142 return ERROR_INT(
"outroot undefined or empty", __func__, 1);
145 pixaca = (
PIXAC **)LEPT_CALLOC(nparts,
sizeof(
PIXAC *));
146 for (i = 0; i < nparts; i++)
152 for (pageno = 0; pageno < npage; pageno++) {
154 L_ERROR(
"pix for page %d not found\n", __func__, pageno);
159 res = pixGetXRes(pix1);
160 if (res == 0 || res == 300 || res > 600) {
163 factor = 300.0 / (l_float32)res;
165 L_WARNING(
"resolution is very low\n", __func__);
166 pix2 =
pixScale(pix1, factor, factor);
174 L_ERROR(
"pix for page %d not deskewed\n", __func__, pageno);
181 boxa1 = pixLocateStaveSets(pix1, pageno, pixadb);
192 lept_stderr(
"number of boxes in page %d: %d\n", pageno, nbox);
193 for (i = 0; i < nbox; i++, line++) {
194 snprintf(buf,
sizeof(buf),
"%d", line);
200 boxaRemoveVGaps(boxa3);
203 L_WARNING(
"nparts requested = %d, but only found %d\n",
204 __func__, nparts, icount);
205 for (j = 0; j < icount && j < nparts; j++) {
209 pixGetHeight(pix1) - 1);
228 for (i = 0; i < nparts; i++) {
229 snprintf(buf,
sizeof(buf),
"%s-%d.pdf", outroot, i);
230 L_INFO(
"writing part %d: %s\n", __func__, i, buf);
249 pixLocateStaveSets(
PIX *pixs,
253 BOXA *boxa1, *boxa2, *boxa3, *boxa4;
265 pixDisplay(pix2, 100 * pageno, 100);
270 boxaRemoveVGaps(boxa3);
275 pixDisplay(pix2, 100 * pageno, 600);
297 boxaRemoveVGaps(
BOXA *boxa)
299 l_int32 nbox, i, y1, h1, y2, h2, delta;
302 for (i = 0; i < nbox - 1; i++) {
305 delta = (y2 - y1 - h1) / 2;
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()
void boxDestroy(BOX **pbox)
boxDestroy()
l_ok boxaGetBoxGeometry(BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxaGetBoxGeometry()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_int32 boxaGetCount(const BOXA *boxa)
boxaGetCount()
BOX * boxaGetBox(BOXA *boxa, l_int32 index, l_int32 accessflag)
boxaGetBox()
l_ok boxSetSideLocations(BOX *box, l_int32 l, l_int32 r, l_int32 t, l_int32 b)
boxSetSideLocations()
l_ok boxaAdjustBoxSides(BOXA *boxa, l_int32 index, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxaAdjustBoxSides()
BOXA * boxaTransform(BOXA *boxas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
boxaTransform()
BOXA * boxaSort(BOXA *boxas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex)
boxaSort()
BOXA * boxaSelectByArea(BOXA *boxas, l_int32 area, l_int32 relation, l_int32 *pchanged)
boxaSelectByArea()
BOXA * pixConnCompBB(PIX *pixs, l_int32 connectivity)
pixConnCompBB()
l_ok pixRenderBoxaArb(PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxaArb()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
l_ok partifyFiles(const char *dirname, const char *substr, l_int32 nparts, const char *outroot, const char *debugfile)
partifyFiles()
l_ok partifyPixac(PIXAC *pixac, l_int32 nparts, const char *outroot, PIXA *pixadb)
partifyPixac()
l_ok pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixClone(PIX *pixs)
pixClone()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
void pixacompDestroy(PIXAC **ppixac)
pixacompDestroy()
PIXAC * pixacompCreateFromFiles(const char *dirname, const char *substr, l_int32 comptype)
pixacompCreateFromFiles()
PIXAC * pixacompCreate(l_int32 n)
pixacompCreate()
l_ok pixacompConvertToPdf(PIXAC *pixac, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixacompConvertToPdf()
l_int32 pixacompGetCount(PIXAC *pixac)
pixacompGetCount()
l_ok pixacompAddPix(PIXAC *pixac, PIX *pix, l_int32 comptype)
pixacompAddPix()
PIX * pixacompGetPix(PIXAC *pixac, l_int32 index)
pixacompGetPix()
PIX * pixConvertTo1Adaptive(PIX *pixs)
pixConvertTo1Adaptive()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
PIX * pixDeskew(PIX *pixs, l_int32 redsearch)
pixDeskew()
PIX * pixAddTextlines(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location)
pixAddTextlines()
void lept_stderr(const char *fmt,...)
lept_stderr()