本文整理汇总了C++中pixaCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ pixaCreate函数的具体用法?C++ pixaCreate怎么用?C++ pixaCreate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pixaCreate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: recogCreate
/*!
* recogCreate()
*
* Input: scalew (scale all widths to this; use 0 for no scaling)
* scaleh (scale all heights to this; use 0 for no scaling)
* templ_type (L_USE_AVERAGE or L_USE_ALL)
* threshold (for binarization; typically ~128)
* maxyshift (from nominal centroid alignment; typically 0 or 1)
* Return: recog, or null on error
*
* Notes:
* (1) For a set trained on one font, such as numbers in a book,
* it is sensible to set scalew = scaleh = 0.
* (2) For a mixed training set, scaling to a fixed height,
* such as 32 pixels, but leaving the width unscaled, is effective.
* (3) The storage for most of the arrays is allocated when training
* is finished.
*/
L_RECOG *
recogCreate(l_int32 scalew,
l_int32 scaleh,
l_int32 templ_type,
l_int32 threshold,
l_int32 maxyshift)
{
L_RECOG *recog;
PIXA *pixa;
PIXAA *paa;
PROCNAME("recogCreate");
if (scalew < 0 || scaleh < 0)
return (L_RECOG *)ERROR_PTR("invalid scalew or scaleh", procName, NULL);
if (templ_type != L_USE_AVERAGE && templ_type != L_USE_ALL)
return (L_RECOG *)ERROR_PTR("invalid templ_type flag", procName, NULL);
if (threshold < 1 || threshold > 255)
return (L_RECOG *)ERROR_PTR("invalid threshold", procName, NULL);
if ((recog = (L_RECOG *)CALLOC(1, sizeof(L_RECOG))) == NULL)
return (L_RECOG *)ERROR_PTR("rec not made", procName, NULL);
recog->templ_type = templ_type;
recog->threshold = threshold;
recog->scalew = scalew;
recog->scaleh = scaleh;
recog->maxyshift = maxyshift;
recog->asperity_fr = DEFAULT_ASPERITY_FRACT;
recogSetPadParams(recog, NULL, NULL, NULL, -1, -1, -1);
recog->bmf = bmfCreate(NULL, 6);
recog->bmf_size = 6;
recog->maxarraysize = MAX_EXAMPLES_IN_CLASS;
recog->index = -1;
/* Generate the LUTs */
recog->centtab = makePixelCentroidTab8();
recog->sumtab = makePixelSumTab8();
recog->sa_text = sarrayCreate(0);
recog->dna_tochar = l_dnaCreate(0);
/* Input default values for min component size for splitting.
* These are overwritten when pixTrainingFinished() is called. */
recog->min_splitw = 6;
recog->min_splith = 6;
recog->max_splith = 60;
/* Generate the storage for the unscaled training bitmaps */
paa = pixaaCreate(recog->maxarraysize);
pixa = pixaCreate(1);
pixaaInitFull(paa, pixa);
pixaDestroy(&pixa);
recog->pixaa_u = paa;
/* Generate the storage for debugging */
recog->pixadb_boot = pixaCreate(2);
recog->pixadb_split = pixaCreate(2);
return recog;
}
开发者ID:Dhavalc2012,项目名称:Opticial-Character-Recognisation,代码行数:76,代码来源:recogbasic.c
示例2: pixaaCreateFromPixa
/*!
* pixaaCreateFromPixa()
*
* Input: pixa
* n (number specifying subdivision of pixa)
* type (L_CHOOSE_CONSECUTIVE, L_CHOOSE_SKIP_BY)
* copyflag (L_CLONE, L_COPY)
* Return: pixaa, or null on error
*
* Notes:
* (1) This subdivides a pixa into a set of smaller pixa that
* are accumulated into a pixaa.
* (2) If type == L_CHOOSE_CONSECUTIVE, the first 'n' pix are
* put in a pixa and added to pixaa, then the next 'n', etc.
* If type == L_CHOOSE_SKIP_BY, the first pixa is made by
* aggregating pix[0], pix[n], pix[2*n], etc.
* (3) The copyflag specifies if each new pix is a copy or a clone.
*/
PIXAA *
pixaaCreateFromPixa(PIXA *pixa,
l_int32 n,
l_int32 type,
l_int32 copyflag)
{
l_int32 count, i, j, npixa;
PIX *pix;
PIXA *pixat;
PIXAA *pixaa;
PROCNAME("pixaaCreateFromPixa");
if (!pixa)
return (PIXAA *)ERROR_PTR("pixa not defined", procName, NULL);
count = pixaGetCount(pixa);
if (count == 0)
return (PIXAA *)ERROR_PTR("no pix in pixa", procName, NULL);
if (n <= 0)
return (PIXAA *)ERROR_PTR("n must be > 0", procName, NULL);
if (type != L_CHOOSE_CONSECUTIVE && type != L_CHOOSE_SKIP_BY)
return (PIXAA *)ERROR_PTR("invalid type", procName, NULL);
if (copyflag != L_CLONE && copyflag != L_COPY)
return (PIXAA *)ERROR_PTR("invalid copyflag", procName, NULL);
if (type == L_CHOOSE_CONSECUTIVE)
npixa = (count + n - 1) / n;
else /* L_CHOOSE_SKIP_BY */
npixa = L_MIN(n, count);
pixaa = pixaaCreate(npixa);
if (type == L_CHOOSE_CONSECUTIVE) {
for (i = 0; i < count; i++) {
if (i % n == 0)
pixat = pixaCreate(n);
pix = pixaGetPix(pixa, i, copyflag);
pixaAddPix(pixat, pix, L_INSERT);
if (i % n == n - 1)
pixaaAddPixa(pixaa, pixat, L_INSERT);
}
if (i % n != 0)
pixaaAddPixa(pixaa, pixat, L_INSERT);
}
else { /* L_CHOOSE_SKIP_BY */
for (i = 0; i < npixa; i++) {
pixat = pixaCreate(count / npixa + 1);
for (j = i; j < count; j += n) {
pix = pixaGetPix(pixa, j, copyflag);
pixaAddPix(pixat, pix, L_INSERT);
}
pixaaAddPixa(pixaa, pixat, L_INSERT);
}
}
return pixaa;
}
开发者ID:AngusHardie,项目名称:TesseractOCR-For-Mac,代码行数:73,代码来源:pixabasic.c
示例3: main
int main(int argc,
char **argv)
{
PIX *pixs, *pixd;
PIXA *pixa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pixs = pixRead("stampede2.jpg");
pixa = pixaCreate(0);
pixSaveTiled(pixs, pixa, 1.0, 1, 20, 8);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 18, 40, 40, 0.7, -25, 280, 128);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 18, 40, 40, 0.7, -25, 280, 128);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 10, 40, 40, 0.7, -15, 305, 128);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 10, 40, 40, 0.7, -15, 305, 128);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 15, 40, 40, 0.6, -45, 285, 158);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 15, 40, 40, 0.6, -45, 285, 158);
pixDestroy(&pixs);
pixd = pixaDisplay(pixa, 0, 0);
regTestWritePixAndCheck(rp, pixd, IFF_JFIF_JPEG); /* 0 */
pixDisplayWithTitle(pixd, 100, 100, NULL, rp->display);
pixDestroy(&pixd);
pixaDestroy(&pixa);
return regTestCleanup(rp);
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:30,代码来源:threshnorm_reg.c
示例4: AddTransformsYUV
void
AddTransformsYUV(PIXA *pixa,
L_BMF *bmf,
l_int32 yval)
{
char textbuf[256];
l_int32 i, j, wpls;
l_uint32 *datas, *lines;
PIX *pixs, *pixt1, *pixt2, *pixt3, *pixt4;
PIXA *pixat;
pixs = pixCreate(225, 225, 32);
wpls = pixGetWpl(pixs);
datas = pixGetData(pixs);
for (i = 0; i < 225; i++) { /* v */
lines = datas + i * wpls;
for (j = 0; j < 225; j++) /* u */
composeRGBPixel(yval + 16, j + 16, i + 16, lines + j);
}
pixat = pixaCreate(3);
pixaAddPix(pixat, pixs, L_INSERT);
pixt1 = pixConvertYUVToRGB(NULL, pixs);
pixaAddPix(pixat, pixt1, L_INSERT);
pixt2 = pixConvertRGBToYUV(NULL, pixt1);
pixaAddPix(pixat, pixt2, L_INSERT);
pixt3 = pixaDisplayTiledAndScaled(pixat, 32, 225, 3, 0, 20, 2);
snprintf(textbuf, sizeof(textbuf), "yval = %d", yval);
pixt4 = pixAddSingleTextblock(pixt3, bmf, textbuf, 0xff000000,
L_ADD_BELOW, NULL);
pixaAddPix(pixa, pixt4, L_INSERT);
pixDestroy(&pixt3);
pixaDestroy(&pixat);
return;
}
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:35,代码来源:yuvtest.c
示例5: pixaReadFilesSA
/*!
* pixaReadFilesSA()
*
* Input: sarray (full pathnames for all files)
* Return: pixa, or null on error
*/
PIXA *
pixaReadFilesSA(SARRAY *sa)
{
char *str;
l_int32 i, n;
PIX *pix;
PIXA *pixa;
PROCNAME("pixaReadFilesSA");
if (!sa)
return (PIXA *)ERROR_PTR("sa not defined", procName, NULL);
n = sarrayGetCount(sa);
pixa = pixaCreate(n);
for (i = 0; i < n; i++) {
str = sarrayGetString(sa, i, L_NOCOPY);
if ((pix = pixRead(str)) == NULL) {
L_WARNING("pix not read from file %s\n", procName, str);
continue;
}
pixaAddPix(pixa, pix, L_INSERT);
}
return pixa;
}
开发者ID:kangwang1988,项目名称:iPdfParser,代码行数:32,代码来源:readfile.c
示例6: main
main(int argc,
char **argv)
{
l_int32 i;
PIX *pix;
PIXA *pixa;
for (i = 0; i < NTests; i++)
GenerateSplitPlot(i);
/* Read the results back in ... */
pixa = pixaCreate(0);
for (i = 0; i < NTests; i++) {
sprintf(buf, "/tmp/junkplot.%d.png", i);
pix = pixRead(buf);
pixSaveTiled(pix, pixa, 1, 1, 25, 32);
pixDestroy(&pix);
sprintf(buf, "/tmp/junkplots.%d.png", i);
pix = pixRead(buf);
pixSaveTiled(pix, pixa, 1, 0, 25, 32);
pixDestroy(&pix);
}
/* ... and save into a tiled pix */
pix = pixaDisplay(pixa, 0, 0);
pixWrite("/tmp/junkotsuplot.png", pix, IFF_PNG);
pixDisplay(pix, 100, 100);
pixaDestroy(&pixa);
pixDestroy(&pix);
return 0;
}
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:31,代码来源:otsutest1.c
示例7: GetImageMask
static void
GetImageMask(PIX *pixs,
l_int32 res,
BOXA **pboxa,
const char *debugfile)
{
PIX *pix1, *pix2, *pix3, *pix4;
PIXA *pixa;
pixSetResolution(pixs, 200, 200);
pix1 = pixConvertTo1(pixs, 100);
pix2 = pixGenerateHalftoneMask(pix1, NULL, NULL, NULL);
pix3 = pixMorphSequence(pix2, "c20.1 + c1.20", 0);
*pboxa = pixConnComp(pix3, NULL, 8);
if (debugfile) {
pixa = pixaCreate(0);
pixaAddPix(pixa, pixs, L_COPY);
pixaAddPix(pixa, pix1, L_INSERT);
pixaAddPix(pixa, pix2, L_INSERT);
pixaAddPix(pixa, pix3, L_INSERT);
pix4 = pixaDisplayTiledInRows(pixa, 32, 1800, 0.25, 0, 25, 2);
pixWrite(debugfile, pix4, IFF_JFIF_JPEG);
pixDisplay(pix4, 100, 100);
pixDestroy(&pix4);
pixaDestroy(&pixa);
} else {
pixDestroy(&pix1);
pixDestroy(&pix2);
pixDestroy(&pix3);
}
return;
}
开发者ID:MaTriXy,项目名称:tess-two,代码行数:33,代码来源:pdfiotest.c
示例8: pixaModifyStrokeWidth
/*!
* \brief pixaModifyStrokeWidth()
*
* \param[in] pixas of 1 bpp pix
* \param[out] targetw desired width for strokes in each pix
* \return pixa with modified stroke widths, or NULL on error
*/
PIXA *
pixaModifyStrokeWidth(PIXA *pixas,
l_float32 targetw)
{
l_int32 i, n, same, maxd;
l_float32 width;
NUMA *na;
PIX *pix1, *pix2;
PIXA *pixad;
PROCNAME("pixaModifyStrokeWidth");
if (!pixas)
return (PIXA *)ERROR_PTR("pixas not defined", procName, NULL);
if (targetw < 1)
return (PIXA *)ERROR_PTR("target width < 1", procName, NULL);
pixaVerifyDepth(pixas, &same, &maxd);
if (maxd > 1)
return (PIXA *)ERROR_PTR("pix not all 1 bpp", procName, NULL);
na = pixaFindStrokeWidth(pixas, 0.1, NULL, 0);
n = pixaGetCount(pixas);
pixad = pixaCreate(n);
for (i = 0; i < n; i++) {
pix1 = pixaGetPix(pixas, i, L_CLONE);
numaGetFValue(na, i, &width);
pix2 = pixModifyStrokeWidth(pix1, width, targetw);
pixaAddPix(pixad, pix2, L_INSERT);
pixDestroy(&pix1);
}
numaDestroy(&na);
return pixad;
}
开发者ID:creatale,项目名称:node-dv,代码行数:41,代码来源:strokes.c
示例9: pixaSortByIndex
/*!
* pixaSortByIndex()
*
* Input: pixas
* naindex (na that maps from the new pixa to the input pixa)
* copyflag (L_COPY, L_CLONE)
* Return: pixad (sorted), or null on error
*/
PIXA *
pixaSortByIndex(PIXA *pixas,
NUMA *naindex,
l_int32 copyflag)
{
l_int32 i, n, index;
BOX *box;
PIX *pix;
PIXA *pixad;
PROCNAME("pixaSortByIndex");
if (!pixas)
return (PIXA *)ERROR_PTR("pixas not defined", procName, NULL);
if (!naindex)
return (PIXA *)ERROR_PTR("naindex not defined", procName, NULL);
if (copyflag != L_CLONE && copyflag != L_COPY)
return (PIXA *)ERROR_PTR("invalid copyflag", procName, NULL);
n = pixaGetCount(pixas);
pixad = pixaCreate(n);
for (i = 0; i < n; i++) {
numaGetIValue(naindex, i, &index);
pix = pixaGetPix(pixas, index, copyflag);
box = pixaGetBox(pixas, index, copyflag);
pixaAddPix(pixad, pix, L_INSERT);
pixaAddBox(pixad, box, L_INSERT);
}
return pixad;
}
开发者ID:ONLYOFFICE,项目名称:core,代码行数:39,代码来源:pixafunc1.cpp
示例10: pixaSetStrokeWidth
/*!
* \brief pixaSetStrokeWidth()
*
* \param[in] pixas of 1 bpp pix
* \param[in] width set stroke width to this value, in [1 ... 100].
* \param[in] thinfirst 1 to thin all pix to a skeleton first; 0 to skip
* \param[in] connectivity 4 or 8, to be used if %thinfirst == 1
* \return pixa with all stroke widths being %width, or NULL on error
*
* <pre>
* Notes:
* (1) If %thinfirst == 1, thin to a skeleton using the specified
* %connectivity. Use %thinfirst == 0 if all pix in pixas
* have already been thinned as far as possible.
* (2) The image is dilated to the required %width. This dilation
* is not connectivity preserving, so this is typically
* used in a situation where merging of c.c. in the individual
* pix is not a problem; e.g., where each pix is a single c.c.
* </pre>
*/
PIXA *
pixaSetStrokeWidth(PIXA *pixas,
l_int32 width,
l_int32 thinfirst,
l_int32 connectivity)
{
l_int32 i, n, maxd, same;
PIX *pix1, *pix2;
PIXA *pixad;
PROCNAME("pixaSetStrokeWidth");
if (!pixas)
return (PIXA *)ERROR_PTR("pixas not defined", procName, NULL);
if (width < 1 || width > 100)
return (PIXA *)ERROR_PTR("width not in [1 ... 100]", procName, NULL);
if (connectivity != 4 && connectivity != 8)
return (PIXA *)ERROR_PTR("connectivity not 4 or 8", procName, NULL);
pixaVerifyDepth(pixas, &same, &maxd);
if (maxd > 1)
return (PIXA *)ERROR_PTR("pix are not all 1 bpp", procName, NULL);
n = pixaGetCount(pixas);
pixad = pixaCreate(n);
for (i = 0; i < n; i++) {
pix1 = pixaGetPix(pixas, i, L_CLONE);
pix2 = pixSetStrokeWidth(pix1, width, thinfirst, connectivity);
pixaAddPix(pixad, pix2, L_INSERT);
pixDestroy(&pix1);
}
return pixad;
}
开发者ID:creatale,项目名称:node-dv,代码行数:53,代码来源:strokes.c
示例11: ReconstructPixa1
/* Reconstruction without compaction */
static PIXA *
ReconstructPixa1(L_PTRA *papix,
L_PTRA *pabox)
{
l_int32 i, imax, nactual;
BOX *box;
PIX *pix;
PIXA *pixat;
ptraGetMaxIndex(papix, &imax);
ptraGetActualCount(papix, &nactual);
fprintf(stderr, "Before removal: imax = %4d, actual = %4d\n",
imax, nactual);
pixat = pixaCreate(imax + 1);
for (i = 0; i <= imax; i++) {
pix = (PIX *)ptraRemove(papix, i, L_NO_COMPACTION);
box = (BOX *)ptraRemove(pabox, i, L_NO_COMPACTION);
if (pix) pixaAddPix(pixat, pix, L_INSERT);
if (box) pixaAddBox(pixat, box, L_INSERT);
}
ptraGetMaxIndex(papix, &imax);
ptraGetActualCount(papix, &nactual);
fprintf(stderr, "After removal: imax = %4d, actual = %4d\n\n",
imax, nactual);
return pixat;
}
开发者ID:dreamplayerzhang,项目名称:leptonica,代码行数:30,代码来源:ptra1_reg.c
示例12: PixSavePlots1
static PIXA *
PixSavePlots1(void)
{
PIX *pixt;
PIXA *pixa;
pixa = pixaCreate(8);
pixt = pixRead("/tmp/rtnan.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnar.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnai.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnarbin.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnabb.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnared.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnagreen.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnablue.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
return pixa;
}
开发者ID:AngusHardie,项目名称:TesseractOCR-For-Mac,代码行数:33,代码来源:rankhisto_reg.c
示例13: CopyStoreClean
void
CopyStoreClean(PIXA *pixas,
l_int32 nlevels,
l_int32 ncopies)
{
l_int32 i, j;
PIX *pix, *pixt;
PIXA *pixa;
PIXAA *paa;
paa = pixaaCreate(0);
for (i = 0; i < nlevels ; i++) {
pixa = pixaCreate(0);
pixaaAddPixa(paa, pixa, L_INSERT);
pix = pixaGetPix(pixas, i, L_CLONE);
for (j = 0; j < ncopies; j++) {
pixt = pixCopy(NULL, pix);
pixaAddPix(pixa, pixt, L_INSERT);
}
pixDestroy(&pix);
}
pixaaDestroy(&paa);
return;
}
开发者ID:xmarston,项目名称:BillRecognizer,代码行数:25,代码来源:pixalloc_reg.c
示例14: pixaClipToPix
/*!
* pixaClipToPix()
*
* Input: pixas
* pixs
* Return: pixad, or null on error
*
* Notes:
* (1) This is intended for use in situations where pixas
* was originally generated from the input pixs.
* (2) Returns a pixad where each pix in pixas is ANDed
* with its associated region of the input pixs. This
* region is specified by the the box that is associated
* with the pix.
* (3) In a typical application of this function, pixas has
* a set of region masks, so this generates a pixa of
* the parts of pixs that correspond to each region
* mask component, along with the bounding box for
* the region.
*/
PIXA *
pixaClipToPix(PIXA *pixas,
PIX *pixs)
{
l_int32 i, n;
BOX *box;
PIX *pix, *pixc;
PIXA *pixad;
PROCNAME("pixaClipToPix");
if (!pixas)
return (PIXA *)ERROR_PTR("pixas not defined", procName, NULL);
if (!pixs)
return (PIXA *)ERROR_PTR("pixs not defined", procName, NULL);
n = pixaGetCount(pixas);
if ((pixad = pixaCreate(n)) == NULL)
return (PIXA *)ERROR_PTR("pixad not made", procName, NULL);
for (i = 0; i < n; i++) {
pix = pixaGetPix(pixas, i, L_CLONE);
box = pixaGetBox(pixas, i, L_COPY);
pixc = pixClipRectangle(pixs, box, NULL);
pixAnd(pixc, pixc, pix);
pixaAddPix(pixad, pixc, L_INSERT);
pixaAddBox(pixad, box, L_INSERT);
pixDestroy(&pix);
}
return pixad;
}
开发者ID:ONLYOFFICE,项目名称:core,代码行数:52,代码来源:pixafunc1.cpp
示例15: main
main(int argc,
char **argv)
{
l_int32 w;
PIX *pixs, *pixt, *pixd;
PIXA *pixa;
static char mainName[] = "smoothedge_reg";
pixs = pixRead("raggededge.png");
w = pixGetWidth(pixs);
pixa = pixaCreate(0);
PixAddEdgeData(pixa, pixs, L_FROM_RIGHT, MIN_JUMP, MIN_REVERSAL);
PixAddEdgeData(pixa, pixs, L_FROM_LEFT, MIN_JUMP, MIN_REVERSAL);
pixt = pixRotateOrth(pixs, 1);
PixAddEdgeData(pixa, pixt, L_FROM_BOTTOM, MIN_JUMP, MIN_REVERSAL);
PixAddEdgeData(pixa, pixt, L_FROM_TOP, MIN_JUMP, MIN_REVERSAL);
pixDestroy(&pixt);
pixt = pixRotateOrth(pixs, 2);
PixAddEdgeData(pixa, pixt, L_FROM_LEFT, MIN_JUMP, MIN_REVERSAL);
PixAddEdgeData(pixa, pixt, L_FROM_RIGHT, MIN_JUMP, MIN_REVERSAL);
pixDestroy(&pixt);
pixt = pixRotateOrth(pixs, 3);
PixAddEdgeData(pixa, pixt, L_FROM_TOP, MIN_JUMP, MIN_REVERSAL);
PixAddEdgeData(pixa, pixt, L_FROM_BOTTOM, MIN_JUMP, MIN_REVERSAL);
pixDestroy(&pixt);
pixDestroy(&pixs);
/* Display at 2x scaling */
pixd = pixaDisplayTiledAndScaled(pixa, 32, 2 * (w + 10), 2, 0, 25, 2);
pixWrite("/tmp/junkpixd.png", pixd, IFF_PNG);
pixDestroy(&pixd);
pixaDestroy(&pixa);
return 0;
}
开发者ID:0359xiaodong,项目名称:tess-two,代码行数:34,代码来源:smoothedge_reg.c
示例16: main
int main(int argc,
char **argv)
{
l_float32 fcolor;
PIX *pix1, *pix2, *pix3, *pix4;
PIXA *pixadb;
static char mainName[] = "find_colorregions";
lept_mkdir("lept/color");
pix1 = pixRead("colorpage.030.jpg");
/* pix1 = pixRead("map.057.jpg"); */
/* More general method */
pixadb = pixaCreate(0);
pixFindColorRegions(pix1, NULL, 4, 200, 60, 10, 90, 0.05,
&fcolor, &pix3, &pix4, pixadb);
fprintf(stderr, "ncolor = %f\n", fcolor);
if (pix3) pixDisplay(pix3, 0, 800);
if (pix4) pixDisplay(pix4, 600, 800);
pix2 = pixaDisplayTiledInColumns(pixadb, 5, 0.3, 20, 2);
pixDisplay(pix2, 0, 0);
pixWrite("/tmp/lept/color/result1.png", pix2, IFF_PNG);
pixDestroy(&pix2);
pixDestroy(&pix3);
pixDestroy(&pix4);
pixaDestroy(&pixadb);
/* Method for pages with very light background */
pixadb = pixaCreate(0);
pixFindColorRegionsLight(pix1, NULL, 4, 60, 230, 40, 20,
&fcolor, &pix3, &pix4, pixadb);
fprintf(stderr, "ncolor = %f\n", fcolor);
if (pix3) pixDisplay(pix3, 1100, 800);
if (pix4) pixDisplay(pix4, 1700, 800);
pix2 = pixaDisplayTiledInColumns(pixadb, 5, 0.3, 20, 2);
pixDisplay(pix2, 1100, 0);
pixWrite("/tmp/lept/color/result2.png", pix2, IFF_PNG);
pixDestroy(&pix2);
pixDestroy(&pix3);
pixDestroy(&pix4);
pixaDestroy(&pixadb);
pixDestroy(&pix1);
return 0;
}
开发者ID:renard314,项目名称:tess-two,代码行数:47,代码来源:find_colorregions.c
示例17: ReconstructPixa2
/* Reconstruction with compaction */
static PIXA *
ReconstructPixa2(L_PTRA *papix,
L_PTRA *pabox)
{
l_int32 i, imax, nactual;
BOX *box;
PIX *pix;
PIXA *pixat;
ptraGetMaxIndex(papix, &imax);
ptraGetActualCount(papix, &nactual);
fprintf(stderr, "Before removal: imax = %4d, actual = %4d\n",
imax, nactual);
/* Remove half */
pixat = pixaCreate(imax + 1);
for (i = 0; i <= imax; i++) {
if (i % 2 == 0) {
pix = (PIX *)ptraRemove(papix, i, L_NO_COMPACTION);
box = (BOX *)ptraRemove(pabox, i, L_NO_COMPACTION);
if (pix) pixaAddPix(pixat, pix, L_INSERT);
if (box) pixaAddBox(pixat, box, L_INSERT);
}
}
/* Compact */
ptraGetMaxIndex(papix, &imax);
ptraGetActualCount(papix, &nactual);
fprintf(stderr, "Before compaction: imax = %4d, actual = %4d\n",
imax, nactual);
ptraCompactArray(papix);
ptraCompactArray(pabox);
ptraGetMaxIndex(papix, &imax);
ptraGetActualCount(papix, &nactual);
fprintf(stderr, "After compaction: imax = %4d, actual = %4d\n",
imax, nactual);
/* Remove the rest (and test compaction with removal) */
while (1) {
ptraGetActualCount(papix, &nactual);
if (nactual == 0) break;
pix = (PIX *)ptraRemove(papix, 0, L_COMPACTION);
box = (BOX *)ptraRemove(pabox, 0, L_COMPACTION);
pixaAddPix(pixat, pix, L_INSERT);
pixaAddBox(pixat, box, L_INSERT);
}
ptraGetMaxIndex(papix, &imax);
ptraGetActualCount(papix, &nactual);
fprintf(stderr, "After removal: imax = %4d, actual = %4d\n\n",
imax, nactual);
return pixat;
}
开发者ID:dreamplayerzhang,项目名称:leptonica,代码行数:56,代码来源:ptra1_reg.c
示例18: pixaAddBorderGeneral
/*!
* pixaAddBorderGeneral()
*
* Input: pixad (can be null or equal to pixas)
* pixas (containing pix of all depths; colormap ok)
* left, right, top, bot (number of pixels added)
* val (value of added border pixels)
* Return: pixad (with border added to each pix), including on error
*
* Notes:
* (1) For binary images:
* white: val = 0
* black: val = 1
* For grayscale images:
* white: val = 2 ** d - 1
* black: val = 0
* For rgb color images:
* white: val = 0xffffff00
* black: val = 0
* For colormapped images, use 'index' found this way:
* white: pixcmapGetRankIntensity(cmap, 1.0, &index);
* black: pixcmapGetRankIntensity(cmap, 0.0, &index);
* (2) For in-place replacement of each pix with a bordered version,
* use @pixad = @pixas. To make a new pixa, use @pixad = NULL.
* (3) In both cases, the boxa has sides adjusted as if it were
* expanded by the border.
*/
PIXA *
pixaAddBorderGeneral(PIXA *pixad,
PIXA *pixas,
l_int32 left,
l_int32 right,
l_int32 top,
l_int32 bot,
l_uint32 val)
{
l_int32 i, n, nbox;
BOX *box;
BOXA *boxad;
PIX *pixs, *pixd;
PROCNAME("pixaAddBorderGeneral");
if (!pixas)
return (PIXA *)ERROR_PTR("pixas not defined", procName, pixad);
if (left < 0 || right < 0 || top < 0 || bot < 0)
return (PIXA *)ERROR_PTR("negative border added!", procName, pixad);
if (pixad && (pixad != pixas))
return (PIXA *)ERROR_PTR("pixad defined but != pixas", procName, pixad);
n = pixaGetCount(pixas);
if (!pixad)
pixad = pixaCreate(n);
for (i = 0; i < n; i++) {
pixs = pixaGetPix(pixas, i, L_CLONE);
pixd = pixAddBorderGeneral(pixs, left, right, top, bot, val);
if (pixad == pixas) /* replace */
pixaReplacePix(pixad, i, pixd, NULL);
else
pixaAddPix(pixad, pixd, L_INSERT);
pixDestroy(&pixs);
}
nbox = pixaGetBoxaCount(pixas);
boxad = pixaGetBoxa(pixad, L_CLONE);
for (i = 0; i < nbox; i++) {
if ((box = pixaGetBox(pixas, i, L_COPY)) == NULL) {
L_WARNING_INT("box %d not found", procName, i);
break;
}
boxAdjustSides(box, box, -left, right, -top, bot);
if (pixad == pixas) /* replace */
boxaReplaceBox(boxad, i, box);
else
boxaAddBox(boxad, box, L_INSERT);
}
boxaDestroy(&boxad);
return pixad;
}
开发者ID:ONLYOFFICE,项目名称:core,代码行数:80,代码来源:pixafunc1.cpp
示例19: PlotBoxa
void static
PlotBoxa(L_REGPARAMS *rp,
l_int32 index)
{
BOXA *boxa1, *boxa2;
PIX *pix1, *pix2, *pix3;
PIXA *pixa;
boxa1 = boxaRead(boxafiles[index]);
/* Read and display initial boxa */
boxaPlotSizes(boxa1, NULL, NULL, NULL, &pix1);
boxaPlotSides(boxa1, NULL, NULL, NULL, NULL, NULL, &pix2);
pixa = pixaCreate(2);
pixaAddPix(pixa, pix1, L_INSERT);
pixaAddPix(pixa, pix2, L_INSERT);
pix3 = pixaDisplayTiledInColumns(pixa, 2, 1.0, 20, 2);
regTestWritePixAndCheck(rp, pix3, IFF_PNG); /* 39, 41, 43 */
pixDisplayWithTitle(pix3, 0 + 800 * index, 500, NULL, rp->display);
pixDestroy(&pix3);
pixaDestroy(&pixa);
/* Read and display reconciled boxa */
boxa2 = boxaReconcileSizeByMedian(boxa1, L_CHECK_BOTH, 0.05, 0.04, 1.03,
NULL, NULL, NULL);
boxaPlotSizes(boxa2, NULL, NULL, NULL, &pix1);
boxaPlotSides(boxa2, NULL, NULL, NULL, NULL, NULL, &pix2);
pixa = pixaCreate(2);
pixaAddPix(pixa, pix1, L_INSERT);
pixaAddPix(pixa, pix2, L_INSERT);
pix3 = pixaDisplayTiledInColumns(pixa, 2, 1.0, 20, 2);
regTestWritePixAndCheck(rp, pix3, IFF_PNG); /* 40, 42, 44 */
pixDisplayWithTitle(pix3, 0 + 800 * index, 920, NULL, rp->display);
pixDestroy(&pix3);
pixaDestroy(&pixa);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
}
开发者ID:chewi,项目名称:leptonica,代码行数:38,代码来源:boxa3_reg.c
示例20: main
main(int argc,
char **argv)
{
l_int32 i, k, x, y, w, h;
BOX *box;
BOXA *boxa1, *boxa2;
PIX *pix1, *pix2, *pixd;
PIXA *pixa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
for (k = 0; k < 7; k++) {
srand(45617);
pixa = pixaCreate(2);
boxa1 = boxaCreate(0);
for (i = 0; i < 500; i++) {
x = (l_int32)(600.0 * (l_float64)rand() / (l_float64)RAND_MAX);
y = (l_int32)(600.0 * (l_float64)rand() / (l_float64)RAND_MAX);
w = (l_int32)
(1.0 + maxsize[k] * (l_float64)rand() / (l_float64)RAND_MAX);
h = (l_int32)
(1.0 + maxsize[k] * (l_float64)rand() / (l_float64)RAND_MAX);
box = boxCreate(x, y, w, h);
boxaAddBox(boxa1, box, L_INSERT);
}
pix1 = pixCreate(660, 660, 1);
pixRenderBoxa(pix1, boxa1, 1, L_SET_PIXELS);
pixaAddPix(pixa, pix1, L_INSERT);
boxa2 = boxaCombineOverlaps(boxa1);
pix2 = pixCreate(660, 660, 1);
pixRenderBoxa(pix2, boxa2, 1, L_SET_PIXELS);
pixaAddPix(pixa, pix2, L_INSERT);
pixd = pixaDisplayTiledInRows(pixa, 1, 1500, 1.0, 0, 50, 2);
pixDisplayWithTitle(pixd, 100, 100 + 100 * k, NULL, rp->display);
regTestWritePixAndCheck(rp, pixd, IFF_PNG);
fprintf(stderr, "%d: n_init = %d, n_final = %d\n",
k, boxaGetCount(boxa1), boxaGetCount(boxa2));
pixDestroy(&pixd);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
pixaDestroy(&pixa);
}
regTestCleanup(rp);
return 0;
}
开发者ID:0359xiaodong,项目名称:tess-two,代码行数:50,代码来源:overlap_reg.c
注:本文中的pixaCreate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论