本文整理汇总了C++中pixaCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ pixaCreate函数的具体用法?C++ pixaCreate怎么用?C++ pixaCreate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pixaCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}