本文整理汇总了C++中pixWrite函数的典型用法代码示例。如果您正苦于以下问题:C++ pixWrite函数的具体用法?C++ pixWrite怎么用?C++ pixWrite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pixWrite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,
char **argv)
{
char filename[BUF_SIZE];
char *dirin, *rootname, *fname;
l_int32 i, firstpage, npages, nfiles;
l_float32 thresh, weight;
JBDATA *data;
JBCLASSER *classer;
SARRAY *safiles;
PIX *pix, *pixt;
PIXA *pixa, *pixadb;
static char mainName[] = "jbcorrelation";
if (argc != 5 && argc != 7)
return ERROR_INT(" Syntax: jbcorrelation dirin thresh weight "
"rootname [firstpage, npages]", mainName, 1);
dirin = argv[1];
thresh = atof(argv[2]);
weight = atof(argv[3]);
rootname = argv[4];
if (argc == 5) {
firstpage = 0;
npages = 0;
}
else {
firstpage = atoi(argv[5]);
npages = atoi(argv[6]);
}
#if 0
/*--------------------------------------------------------------*/
jbCorrelation(dirin, thresh, weight, COMPONENTS, rootname,
firstpage, npages, 1);
/*--------------------------------------------------------------*/
#else
/*--------------------------------------------------------------*/
safiles = getSortedPathnamesInDirectory(dirin, NULL, firstpage, npages);
nfiles = sarrayGetCount(safiles);
sarrayWriteStream(stderr, safiles);
/* Classify components on requested pages */
startTimer();
classer = jbCorrelationInit(COMPONENTS, 0, 0, thresh, weight);
jbAddPages(classer, safiles);
fprintf(stderr, "Time to generate classes: %6.3f sec\n", stopTimer());
/* Save and write out the result */
data = jbDataSave(classer);
jbDataWrite(rootname, data);
fprintf(stderr, "Number of classes: %d\n", classer->nclass);
/* Render the pages from the classifier data.
* Use debugflag == FALSE to omit outlines of each component. */
pixa = jbDataRender(data, FALSE);
/* Write the pages out */
npages = pixaGetCount(pixa);
if (npages != nfiles)
fprintf(stderr, "npages = %d, nfiles = %d, not equal!\n",
npages, nfiles);
for (i = 0; i < npages; i++) {
pix = pixaGetPix(pixa, i, L_CLONE);
snprintf(filename, BUF_SIZE, "%s.%05d", rootname, i);
fprintf(stderr, "filename: %s\n", filename);
pixWrite(filename, pix, IFF_PNG);
pixDestroy(&pix);
}
#if DISPLAY_DIFFERENCE
fname = sarrayGetString(safiles, 0, 0);
pixt = pixRead(fname);
pix = pixaGetPix(pixa, 0, L_CLONE);
pixXor(pixt, pixt, pix);
pixWrite("junk_output_diff", pixt, IFF_PNG);
pixDestroy(&pix);
pixDestroy(&pixt);
#endif /* DISPLAY_DIFFERENCE */
#if DEBUG_TEST_DATA_IO
{ JBDATA *newdata;
PIX *newpix;
PIXA *newpixa;
l_int32 same, iofail;
/* Read the data back in and render the pages */
newdata = jbDataRead(rootname);
newpixa = jbDataRender(newdata, FALSE);
iofail = FALSE;
for (i = 0; i < npages; i++) {
pix = pixaGetPix(pixa, i, L_CLONE);
newpix = pixaGetPix(newpixa, i, L_CLONE);
//.........这里部分代码省略.........
示例2: pixaWriteCompressedToPS
/*
* pixaWriteCompressedToPS()
*
* Input: pixa (any set of images)
* fileout (output ps file)
* res (of input image)
* level (compression: 2 or 3)
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) This generates a PS file of multiple page images, all
* with bounding boxes.
* (2) It compresses to:
* cmap + level2: jpeg
* cmap + level3: flate
* 1 bpp: tiffg4
* 2 or 4 bpp + level2: jpeg
* 2 or 4 bpp + level3: flate
* 8 bpp: jpeg
* 16 bpp: flate
* 32 bpp: jpeg
* (3) To generate a pdf, use: ps2pdf <infile.ps> <outfile.pdf>
*/
l_int32
pixaWriteCompressedToPS(PIXA *pixa,
const char *fileout,
l_int32 res,
l_int32 level)
{
char *tname, *g4_name, *jpeg_name, *png_name;
l_int32 i, n, firstfile, index, writeout, d;
PIX *pix, *pixt;
PIXCMAP *cmap;
PROCNAME("pixaWriteCompressedToPS");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (!fileout)
return ERROR_INT("fileout not defined", procName, 1);
if (level != 2 && level != 3) {
L_ERROR("only levels 2 and 3 permitted; using level 2\n", procName);
level = 2;
}
n = pixaGetCount(pixa);
firstfile = TRUE;
index = 0;
lept_mkdir("lept/comp");
g4_name = genTempFilename("/tmp/lept/comp", "temp.tif", 0, 0);
jpeg_name = genTempFilename("/tmp/lept/comp", "temp.jpg", 0, 0);
png_name = genTempFilename("/tmp/lept/comp", "temp.png", 0, 0);
for (i = 0; i < n; i++) {
writeout = TRUE;
pix = pixaGetPix(pixa, i, L_CLONE);
d = pixGetDepth(pix);
cmap = pixGetColormap(pix);
if (d == 1) {
tname = g4_name;
pixWrite(tname, pix, IFF_TIFF_G4);
} else if (cmap) {
if (level == 2) {
pixt = pixConvertForPSWrap(pix);
tname = jpeg_name;
pixWrite(tname, pixt, IFF_JFIF_JPEG);
pixDestroy(&pixt);
} else { /* level == 3 */
tname = png_name;
pixWrite(tname, pix, IFF_PNG);
}
} else if (d == 16) {
if (level == 2)
L_WARNING("d = 16; must write out flate\n", procName);
tname = png_name;
pixWrite(tname, pix, IFF_PNG);
} else if (d == 2 || d == 4) {
if (level == 2) {
pixt = pixConvertTo8(pix, 0);
tname = jpeg_name;
pixWrite(tname, pixt, IFF_JFIF_JPEG);
pixDestroy(&pixt);
} else { /* level == 3 */
tname = png_name;
pixWrite(tname, pix, IFF_PNG);
}
} else if (d == 8 || d == 32) {
tname = jpeg_name;
pixWrite(tname, pix, IFF_JFIF_JPEG);
} else { /* shouldn't happen */
L_ERROR("invalid depth: %d\n", procName, d);
writeout = FALSE;
}
pixDestroy(&pix);
if (writeout)
writeImageCompressedToPSFile(tname, fileout, res,
&firstfile, &index);
}
LEPT_FREE(g4_name);
//.........这里部分代码省略.........
示例3: DoComparisonDwa1
l_int32
DoComparisonDwa1(PIX *pixs,
PIX *pixt1,
PIX *pixt2,
PIX *pixt3,
PIX *pixt4,
PIX *pixt5,
PIX *pixt6,
l_int32 isize)
{
l_int32 fact1, fact2, size;
selectComposableSizes(isize, &fact1, &fact2);
size = fact1 * fact2;
fprintf(stderr, "..%d..", size);
if (TIMING) startTimer();
pixDilateCompBrickExtendDwa(pixt1, pixs, size, 1);
pixDilateCompBrickExtendDwa(pixt3, pixs, 1, size);
pixDilateCompBrickExtendDwa(pixt5, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer());
if (TIMING) startTimer();
pixDilateCompBrick(pixt2, pixs, size, 1);
pixDilateCompBrick(pixt4, pixs, 1, size);
pixDilateCompBrick(pixt6, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer());
PixCompareDwa(size, "dilate", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6);
if (TIMING) startTimer();
pixErodeCompBrickExtendDwa(pixt1, pixs, size, 1);
pixErodeCompBrickExtendDwa(pixt3, pixs, 1, size);
pixErodeCompBrickExtendDwa(pixt5, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer());
if (TIMING) startTimer();
pixErodeCompBrick(pixt2, pixs, size, 1);
pixErodeCompBrick(pixt4, pixs, 1, size);
pixErodeCompBrick(pixt6, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer());
PixCompareDwa(size, "erode", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6);
if (TIMING) startTimer();
pixOpenCompBrickExtendDwa(pixt1, pixs, size, 1);
pixOpenCompBrickExtendDwa(pixt3, pixs, 1, size);
pixOpenCompBrickExtendDwa(pixt5, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer());
if (TIMING) startTimer();
pixOpenCompBrick(pixt2, pixs, size, 1);
pixOpenCompBrick(pixt4, pixs, 1, size);
pixOpenCompBrick(pixt6, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer());
PixCompareDwa(size, "open", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6);
if (TIMING) startTimer();
pixCloseCompBrickExtendDwa(pixt1, pixs, size, 1);
pixCloseCompBrickExtendDwa(pixt3, pixs, 1, size);
pixCloseCompBrickExtendDwa(pixt5, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer());
if (TIMING) startTimer();
pixCloseSafeCompBrick(pixt2, pixs, size, 1);
pixCloseSafeCompBrick(pixt4, pixs, 1, size);
pixCloseSafeCompBrick(pixt6, pixs, size, size);
if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer());
PixCompareDwa(size, "close", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6);
#if 0
pixWrite("/tmp/junkpixt3.png", pixt3, IFF_PNG);
pixWrite("/tmp/junkpixt4.png", pixt4, IFF_PNG);
pixXor(pixt3, pixt3, pixt4);
pixWrite("/tmp/junkxor.png", pixt3, IFF_PNG);
#endif
return 0;
}
示例4: main
int main(int argc,
char **argv) {
char buf[32];
char *filein, *fileout, *fontdir, *textstr;
l_int32 n, i, maxdepth, ntext, border, lossless, display, showtext;
l_float32 scalefact;
L_BMF *bmf;
PIX *pix1, *pix2, *pix3, *pix4, *pixd;
PIXA *pixa, *pixad;
static char mainName[] = "displaypixa";
if (argc != 3 && argc != 4 && argc != 7 && argc != 8) {
fprintf(stderr, "Syntax error in displaypixa:\n"
" displaypixa filein fileout [showtext]\n"
" displaypixa filein scalefact border"
" lossless disp fileout [showtext]\n");
return 1;
}
filein = argv[1];
if ((pixa = pixaRead(filein)) == NULL)
return ERROR_INT("pixa not made", mainName, 1);
pixaCountText(pixa, &ntext);
if (argc == 3 || argc == 4)
fileout = argv[2];
if (argc == 4)
showtext = atoi(argv[3]);
/* Simple specification; no output text */
if (argc == 3 ||
(argc == 4 && (ntext == 0 || showtext == 0))) { /* no text output */
pixaVerifyDepth(pixa, &maxdepth);
pixd = pixaDisplayTiledInRows(pixa, maxdepth, 1400, 1.0, 0, 10, 0);
pixDisplay(pixd, 100, 100);
if (pixGetDepth(pixd) == 1)
pixWrite(fileout, pixd, IFF_PNG);
else
pixWrite(fileout, pixd, IFF_JFIF_JPEG);
pixDestroy(&pixd);
pixaDestroy(&pixa);
return 0;
}
/* Simple specification with output text */
if (argc == 4) { /* showtext == 1 && ntext > 0 */
n = pixaGetCount(pixa);
bmf = bmfCreate(NULL, 6);
pixad = pixaCreate(n);
for (i = 0; i < n; i++) {
pix1 = pixaGetPix(pixa, i, L_CLONE);
pix2 = pixConvertTo32(pix1);
pix3 = pixAddBorderGeneral(pix2, 10, 10, 5, 5, 0xffffff00);
textstr = pixGetText(pix1);
if (textstr && strlen(textstr) > 0) {
snprintf(buf, sizeof(buf), "%s", textstr);
pix4 = pixAddSingleTextblock(pix3, bmf, buf, 0xff000000,
L_ADD_BELOW, NULL);
} else {
pix4 = pixClone(pix3);
}
pixaAddPix(pixad, pix4, L_INSERT);
pixDestroy(&pix1);
pixDestroy(&pix2);
pixDestroy(&pix3);
}
bmfDestroy(&bmf);
pixaVerifyDepth(pixad, &maxdepth);
pixd = pixaDisplayTiledInRows(pixad, maxdepth, 1400, 1.0, 0, 10, 0);
pixDisplay(pixd, 100, 100);
if (pixGetDepth(pixd) == 1)
pixWrite(fileout, pixd, IFF_PNG);
else
pixWrite(fileout, pixd, IFF_JFIF_JPEG);
pixDestroy(&pixd);
pixaDestroy(&pixa);
pixaDestroy(&pixad);
return 0;
}
/* Full specification */
scalefact = atof(argv[2]);
border = atoi(argv[3]);
lossless = atoi(argv[4]);
display = atoi(argv[5]);
fileout = argv[6];
showtext = (argc == 8) ? atoi(argv[7]) : 0;
if (showtext && ntext == 0)
L_INFO("No text found in any of the pix\n", mainName);
bmf = (showtext && ntext > 0) ? bmfCreate(NULL, 6) : NULL;
n = pixaGetCount(pixa);
pixad = pixaCreate(n);
for (i = 0; i < n; i++) {
pix1 = pixaGetPix(pixa, i, L_CLONE);
pix2 = pixConvertTo32(pix1);
pix3 = pixAddBorderGeneral(pix2, 10, 10, 5, 5, 0xffffff00);
textstr = pixGetText(pix1);
if (bmf && textstr && strlen(textstr) > 0) {
snprintf(buf, sizeof(buf), "%s", textstr);
pix4 = pixAddSingleTextblock(pix3, bmf, buf, 0xff000000,
//.........这里部分代码省略.........
示例5: main
main(int argc,
char **argv)
{
l_int32 d;
PIX *pixs, *pixc, *pixr, *pixg, *pixb, *pixsg, *pixsm, *pixd;
PIXA *pixa;
static char mainName[] = "livre_adapt";
if (argc != 1)
exit(ERROR_INT(" Syntax: livre_adapt", mainName, 1));
/* Read the image in at 150 ppi. */
pixDisplayWrite(NULL, -1);
if ((pixs = pixRead("brothers.150.jpg")) == NULL)
exit(ERROR_INT("pix not made", mainName, 1));
pixDisplayWriteFormat(pixs, 2, IFF_JFIF_JPEG);
/* Normalize for uneven illumination on RGB image */
pixBackgroundNormRGBArraysMorph(pixs, NULL, 4, 5, 200,
&pixr, &pixg, &pixb);
pixd = pixApplyInvBackgroundRGBMap(pixs, pixr, pixg, pixb, 4, 4);
pixDisplayWriteFormat(pixd, 2, IFF_JFIF_JPEG);
pixDestroy(&pixr);
pixDestroy(&pixg);
pixDestroy(&pixb);
pixDestroy(&pixd);
/* Convert the RGB image to grayscale. */
pixsg = pixConvertRGBToLuminance(pixs);
pixDisplayWriteFormat(pixsg, 2, IFF_JFIF_JPEG);
/* Remove the text in the fg. */
pixc = pixCloseGray(pixsg, 25, 25);
pixDisplayWriteFormat(pixc, 2, IFF_JFIF_JPEG);
/* Smooth the bg with a convolution. */
pixsm = pixBlockconv(pixc, 15, 15);
pixDisplayWriteFormat(pixsm, 2, IFF_JFIF_JPEG);
pixDestroy(&pixc);
/* Normalize for uneven illumination on gray image. */
pixBackgroundNormGrayArrayMorph(pixsg, NULL, 4, 5, 200, &pixg);
pixc = pixApplyInvBackgroundGrayMap(pixsg, pixg, 4, 4);
pixDisplayWriteFormat(pixc, 2, IFF_JFIF_JPEG);
pixDestroy(&pixg);
/* Increase the dynamic range. */
pixd = pixGammaTRC(NULL, pixc, 1.0, 30, 180);
pixDisplayWriteFormat(pixd, 2, IFF_JFIF_JPEG);
pixDestroy(&pixc);
/* Threshold to 1 bpp. */
pixb = pixThresholdToBinary(pixd, 120);
pixDisplayWriteFormat(pixb, 2, IFF_PNG);
pixDestroy(&pixd);
pixDestroy(&pixb);
/* Generate the output image */
pixa = pixaReadFiles("/tmp", "junk_write_display");
pixd = pixaDisplayTiledAndScaled(pixa, 8, 350, 4, 0, 25, 2);
pixWrite("/tmp/adapt.jpg", pixd, IFF_JFIF_JPEG);
pixDisplayWithTitle(pixd, 100, 100, NULL, 1);
pixDestroy(&pixd);
pixDestroy(&pixs);
pixDestroy(&pixsg);
return 0;
}
示例6: pixConnCompBB
/*!
* pixConnCompBB()
*
* Input: pixs (1 bpp)
* connectivity (4 or 8)
* Return: boxa, or null on error
*
* Notes:
* (1) Finds bounding boxes of 4- or 8-connected components
* in a binary image.
* (2) This works on a copy of the input pix. The c.c. are located
* in raster order and erased one at a time. In the process,
* the b.b. is computed and saved.
*/
BOXA *
pixConnCompBB(PIX *pixs,
l_int32 connectivity)
{
l_int32 h, iszero;
l_int32 x, y, xstart, ystart;
PIX *pixt;
BOX *box;
BOXA *boxa;
L_STACK *stack, *auxstack;
PROCNAME("pixConnCompBB");
if (!pixs || pixGetDepth(pixs) != 1)
return (BOXA *)ERROR_PTR("pixs undefined or not 1 bpp", procName, NULL);
if (connectivity != 4 && connectivity != 8)
return (BOXA *)ERROR_PTR("connectivity not 4 or 8", procName, NULL);
pixZero(pixs, &iszero);
if (iszero)
return boxaCreate(1); /* return empty boxa */
if ((pixt = pixCopy(NULL, pixs)) == NULL)
return (BOXA *)ERROR_PTR("pixt not made", procName, NULL);
h = pixGetHeight(pixs);
if ((stack = lstackCreate(h)) == NULL)
return (BOXA *)ERROR_PTR("stack not made", procName, NULL);
if ((auxstack = lstackCreate(0)) == NULL)
return (BOXA *)ERROR_PTR("auxstack not made", procName, NULL);
stack->auxstack = auxstack;
if ((boxa = boxaCreate(0)) == NULL)
return (BOXA *)ERROR_PTR("boxa not made", procName, NULL);
xstart = 0;
ystart = 0;
while (1)
{
if (!nextOnPixelInRaster(pixt, xstart, ystart, &x, &y))
break;
if ((box = pixSeedfillBB(pixt, stack, x, y, connectivity)) == NULL)
return (BOXA *)ERROR_PTR("box not made", procName, NULL);
boxaAddBox(boxa, box, L_INSERT);
xstart = x;
ystart = y;
}
#if DEBUG
pixCountPixels(pixt, &iszero, NULL);
fprintf(stderr, "Number of remaining pixels = %d\n", iszero);
pixWrite("junkremain", pixt1, IFF_PNG);
#endif /* DEBUG */
/* Cleanup, freeing the fillsegs on each stack */
lstackDestroy(&stack, TRUE);
pixDestroy(&pixt);
return boxa;
}
示例7: main
//.........这里部分代码省略.........
for (i = 0; i < n; i++) {
pix = pixaGetPix(pixas, i, L_CLONE);
box = pixaGetBox(pixas, i, L_CLONE);
ptraInsert(papix, 0, pix, L_MIN_DOWNSHIFT);
ptraInsert(pabox, 0, box, L_FULL_DOWNSHIFT);
}
pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON);
ptraDestroy(&papix, 0, 1);
ptraDestroy(&pabox, 0, 1);
DisplayResult(pixac, &pixat, w, h, 1);
/* Reverse the arrays by swapping */
fprintf(stderr, "Reverse by swapping\n");
MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE);
for (i = 0; i < n / 2; i++) {
ptraSwap(papix, i, n - i - 1);
ptraSwap(pabox, i, n - i - 1);
}
ptraCompactArray(papix); /* already compact; shouldn't do anything */
ptraCompactArray(pabox);
pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON);
ptraDestroy(&papix, 0, 1);
ptraDestroy(&pabox, 0, 1);
DisplayResult(pixac, &pixat, w, h, 0);
/* Remove at the top of the array and push the hole to the end
* by neighbor swapping (!). This is O(n^2), so it's not a
* recommended way to copy a ptra. [joke] */
fprintf(stderr,
"Remove at top, pushing hole to end by swapping -- O(n^2)\n");
MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE);
papix2 = ptraCreate(0);
pabox2 = ptraCreate(0);
while (1) {
ptraGetActualCount(papix, &nactual);
if (nactual == 0) break;
ptraGetMaxIndex(papix, &imax);
pix = (PIX *)ptraRemove(papix, 0, L_NO_COMPACTION);
box = (BOX *)ptraRemove(pabox, 0, L_NO_COMPACTION);
ptraAdd(papix2, pix);
ptraAdd(pabox2, box);
for (i = 1; i <= imax; i++) {
ptraSwap(papix, i - 1, i);
ptraSwap(pabox, i - 1, i);
}
}
ptraCompactArray(papix); /* should be empty */
ptraCompactArray(pabox); /* ditto */
pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON);
ptraDestroy(&papix, 0, 1);
ptraDestroy(&pabox, 0, 1);
DisplayResult(pixac, &pixat, w, h, 1); /* nothing there */
pixat = ReconstructPixa(papix2, pabox2, CHOOSE_RECON);
ptraDestroy(&papix2, 0, 1);
ptraDestroy(&pabox2, 0, 1);
DisplayResult(pixac, &pixat, w, h, 0);
/* Remove and insert one position above, allowing minimum downshift.
* If you specify L_AUTO_DOWNSHIFT, because there is only 1 hole,
* it will do a full downshift at each insert. This is a
* situation where the heuristic (expected number of holes)
* fails to do the optimal thing. */
fprintf(stderr, "Remove and insert one position above (min downshift)\n");
MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE);
for (i = 1; i < n; i++) {
pix = (PIX *)ptraRemove(papix, i, L_NO_COMPACTION);
box = (BOX *)ptraRemove(pabox, i, L_NO_COMPACTION);
ptraInsert(papix, i - 1, pix, L_MIN_DOWNSHIFT);
ptraInsert(pabox, i - 1, box, L_MIN_DOWNSHIFT);
}
pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON);
ptraDestroy(&papix, 0, 1);
ptraDestroy(&pabox, 0, 1);
DisplayResult(pixac, &pixat, w, h, 1);
/* Remove and insert one position above, but this time
* forcing a full downshift at each step. */
fprintf(stderr, "Remove and insert one position above (full downshift)\n");
MakePtrasFromPixa(pixas, &papix, &pabox, L_CLONE);
for (i = 1; i < n; i++) {
pix = (PIX *)ptraRemove(papix, i, L_NO_COMPACTION);
box = (BOX *)ptraRemove(pabox, i, L_NO_COMPACTION);
ptraInsert(papix, i - 1, pix, L_AUTO_DOWNSHIFT);
ptraInsert(pabox, i - 1, box, L_AUTO_DOWNSHIFT);
}
/* ptraCompactArray(papix);
ptraCompactArray(pabox); */
pixat = ReconstructPixa(papix, pabox, CHOOSE_RECON);
ptraDestroy(&papix, 0, 1);
ptraDestroy(&pabox, 0, 1);
DisplayResult(pixac, &pixat, w, h, 0);
pixd = pixaDisplay(pixac, 0, 0);
pixDisplay(pixd, 100, 100);
pixWrite("/tmp/junkptra1.png", pixd, IFF_PNG);
pixDestroy(&pixd);
pixaDestroy(&pixac);
pixaDestroy(&pixas);
return 0;
}
示例8: main
main(int argc,
char **argv)
{
char *filein, *fileout;
char buffer[512];
const char *psfile = "/tmp/junk_split_image.ps";
l_int32 nx, ny, i, w, h, d, ws, hs, n, res, ignore;
l_float32 scale;
PIX *pixs, *pixt, *pixr;
PIXA *pixa;
static char mainName[] = "splitimage2pdf";
if (argc != 5)
return ERROR_INT(" Syntax: splitimage2pdf filein nx ny fileout",
mainName, 1);
filein = argv[1];
nx = atoi(argv[2]);
ny = atoi(argv[3]);
fileout = argv[4];
lept_rm(NULL, "junk_split_image.ps");
if ((pixs = pixRead(filein)) == NULL)
exit(ERROR_INT("pixs not made", mainName, 1));
d = pixGetDepth(pixs);
if (d == 1 )
lept_rm(NULL, "junk_split_image.tif");
else if (d == 8 || d == 32)
lept_rm(NULL, "junk_split_image.jpg");
else
return ERROR_INT("d not in {1,8,32} bpp", mainName, 1);
ws = pixGetWidth(pixs);
hs = pixGetHeight(pixs);
if (ny * ws > nx * hs)
pixr = pixRotate90(pixs, 1);
else
pixr = pixClone(pixs);
pixa = pixaSplitPix(pixr, nx, ny, 0, 0);
n = pixaGetCount(pixa);
res = 300;
for (i = 0; i < n; i++) {
pixt = pixaGetPix(pixa, i, L_CLONE);
w = pixGetWidth(pixt);
h = pixGetHeight(pixt);
scale = L_MIN(FILL_FACTOR * 2550 / w, FILL_FACTOR * 3300 / h);
if (d == 1) {
pixWrite("/tmp/junk_split_image.tif", pixt, IFF_TIFF_G4);
if (i == 0)
convertG4ToPS("/tmp/junk_split_image.tif", psfile,
"w", 0, 0, 300, scale, 1, FALSE, TRUE);
else
convertG4ToPS("/tmp/junk_split_image.tif", psfile,
"a", 0, 0, 300, scale, 1, FALSE, TRUE);
}
else {
pixWrite("/tmp/junk_split_image.jpg", pixt, IFF_JFIF_JPEG);
if (i == 0)
convertJpegToPS("/tmp/junk_split_image.jpg", psfile,
"w", 0, 0, 300, scale, 1, TRUE);
else
convertJpegToPS("/tmp/junk_split_image.jpg", psfile,
"a", 0, 0, 300, scale, 1, TRUE);
}
pixDestroy(&pixt);
}
sprintf(buffer, "ps2pdf %s %s", psfile, fileout);
ignore = system(buffer);
pixaDestroy(&pixa);
pixDestroy(&pixr);
pixDestroy(&pixs);
return 0;
}
示例9: main_find_pattern
int main_find_pattern(int argc,
char **argv)
{
char *filein, *fileout, *patternfile;
l_int32 w, h, i, n;
BOX *box, *boxe;
BOXA *boxa1, *boxa2;
PIX *pixs, *pixp, *pixpe;
PIX *pixd, *pixt1, *pixt2, *pixhmt;
SEL *sel_2h, *sel;
static char mainName[] = "findpattern1";
filein = "feyn.tif";
patternfile = "char.tif";
fileout = "result.findpattern1";
if ((pixs = pixRead(filein)) == NULL)
printf("pixs not made\n");
if ((pixp = pixRead(patternfile)) == NULL)
printf("pixp not made\n");
w = pixGetWidth(pixp);
h = pixGetHeight(pixp);
/* generate the hit-miss Sel with runs */
sel = pixGenerateSelWithRuns(pixp, NumHorLines, NumVertLines, 0,
MinRunlength, 7, 7, 0, 0, &pixpe);
/* display the Sel two ways */
selWriteStream(stderr, sel);
pixt1 = pixDisplayHitMissSel(pixpe, sel, 9, HitColor, MissColor);
pixDisplay(pixt1, 200, 200);
pixWrite("junkpixt", pixt1, IFF_PNG);
/* use the Sel to find all instances in the page */
startTimer();
pixhmt = pixHMT(NULL, pixs, sel);
fprintf(stderr, "Time to find patterns = %7.3f\n", stopTimer());
/* small erosion to remove noise; typically not necessary if
* there are enough elements in the Sel */
sel_2h = selCreateBrick(1, 2, 0, 0, SEL_HIT);
pixt2 = pixErode(NULL, pixhmt, sel_2h);
/* display the result visually by placing the Sel at each
* location found */
pixd = pixDilate(NULL, pixt2, sel);
pixWrite(fileout, pixd, IFF_TIFF_G4);
/* display outut with an outline around each located pattern */
boxa1 = pixConnCompBB(pixt2, 8);
n = boxaGetCount(boxa1);
boxa2 = boxaCreate(n);
for (i = 0; i < n; i++) {
box = boxaGetBox(boxa1, i, L_COPY);
boxe = boxCreate(box->x - w / 2, box->y - h / 2, w + 4, h + 4);
boxaAddBox(boxa2, boxe, L_INSERT);
pixRenderBox(pixs, boxe, 4, L_FLIP_PIXELS);
boxDestroy(&box);
}
pixWrite("junkoutline", pixs, IFF_TIFF_G4);
//boxaWriteStream(stderr, boxa2); //TODO ???
pixDestroy(&pixs);
pixDestroy(&pixp);
pixDestroy(&pixpe);
pixDestroy(&pixt1);
pixDestroy(&pixt2);
pixDestroy(&pixhmt);
pixDestroy(&pixd);
selDestroy(&sel);
selDestroy(&sel_2h);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
printf("\n---\nEND\n");
getchar();
return 0;
}
示例10: pixWrite
// This method dumps a debug image to the specified location.
void ShiroRekhaSplitter::DumpDebugImage(const char* filename) const {
pixWrite(filename, debug_image_, IFF_PNG);
}
示例11: main
l_int32 main(int argc,
char **argv)
{
l_int32 i, n;
l_float32 a, b, c, d, e;
NUMA *nax, *nafit;
PIX *pixs, *pixn, *pixg, *pixb, *pixt1, *pixt2;
PIXA *pixa;
PTA *pta, *ptad;
PTAA *ptaa1, *ptaa2;
pixs = pixRead("cat-35.jpg");
/* Normalize for varying background and binarize */
pixn = pixBackgroundNormSimple(pixs, NULL, NULL);
pixg = pixConvertRGBToGray(pixn, 0.5, 0.3, 0.2);
pixb = pixThresholdToBinary(pixg, 130);
pixDestroy(&pixn);
pixDestroy(&pixg);
/* Get the textline centers */
pixa = pixaCreate(6);
ptaa1 = dewarpGetTextlineCenters(pixb, 0);
pixt1 = pixCreateTemplate(pixs);
pixSetAll(pixt1);
pixt2 = pixDisplayPtaa(pixt1, ptaa1);
pixWrite("/tmp/textline1.png", pixt2, IFF_PNG);
pixDisplayWithTitle(pixt2, 0, 100, "textline centers 1", 1);
pixaAddPix(pixa, pixt2, L_INSERT);
pixDestroy(&pixt1);
/* Remove short lines */
fprintf(stderr, "Num all lines = %d\n", ptaaGetCount(ptaa1));
ptaa2 = dewarpRemoveShortLines(pixb, ptaa1, 0.8, 0);
pixt1 = pixCreateTemplate(pixs);
pixSetAll(pixt1);
pixt2 = pixDisplayPtaa(pixt1, ptaa2);
pixWrite("/tmp/textline2.png", pixt2, IFF_PNG);
pixDisplayWithTitle(pixt2, 300, 100, "textline centers 2", 1);
pixaAddPix(pixa, pixt2, L_INSERT);
pixDestroy(&pixt1);
n = ptaaGetCount(ptaa2);
fprintf(stderr, "Num long lines = %d\n", n);
ptaaDestroy(&ptaa1);
pixDestroy(&pixb);
/* Long lines over input image */
pixt1 = pixCopy(NULL, pixs);
pixt2 = pixDisplayPtaa(pixt1, ptaa2);
pixWrite("/tmp/textline3.png", pixt2, IFF_PNG);
pixDisplayWithTitle(pixt2, 600, 100, "textline centers 3", 1);
pixaAddPix(pixa, pixt2, L_INSERT);
pixDestroy(&pixt1);
/* Quadratic fit to curve */
pixt1 = pixCopy(NULL, pixs);
for (i = 0; i < n; i++) {
pta = ptaaGetPta(ptaa2, i, L_CLONE);
ptaGetArrays(pta, &nax, NULL);
ptaGetQuadraticLSF(pta, &a, &b, &c, &nafit);
fprintf(stderr, "Quadratic: a = %10.6f, b = %7.3f, c = %7.3f\n",
a, b, c);
ptad = ptaCreateFromNuma(nax, nafit);
pixDisplayPta(pixt1, pixt1, ptad);
ptaDestroy(&pta);
ptaDestroy(&ptad);
numaDestroy(&nax);
numaDestroy(&nafit);
}
pixWrite("/tmp/textline4.png", pixt1, IFF_PNG);
pixDisplayWithTitle(pixt1, 900, 100, "textline centers 4", 1);
pixaAddPix(pixa, pixt1, L_INSERT);
/* Cubic fit to curve */
pixt1 = pixCopy(NULL, pixs);
for (i = 0; i < n; i++) {
pta = ptaaGetPta(ptaa2, i, L_CLONE);
ptaGetArrays(pta, &nax, NULL);
ptaGetCubicLSF(pta, &a, &b, &c, &d, &nafit);
fprintf(stderr, "Cubic: a = %10.6f, b = %10.6f, c = %7.3f, d = %7.3f\n",
a, b, c, d);
ptad = ptaCreateFromNuma(nax, nafit);
pixDisplayPta(pixt1, pixt1, ptad);
ptaDestroy(&pta);
ptaDestroy(&ptad);
numaDestroy(&nax);
numaDestroy(&nafit);
}
pixWrite("/tmp/textline5.png", pixt1, IFF_PNG);
pixDisplayWithTitle(pixt1, 1200, 100, "textline centers 5", 1);
pixaAddPix(pixa, pixt1, L_INSERT);
/* Quartic fit to curve */
pixt1 = pixCopy(NULL, pixs);
for (i = 0; i < n; i++) {
pta = ptaaGetPta(ptaa2, i, L_CLONE);
ptaGetArrays(pta, &nax, NULL);
ptaGetQuarticLSF(pta, &a, &b, &c, &d, &e, &nafit);
fprintf(stderr,
"Quartic: a = %7.3f, b = %7.3f, c = %9.5f, d = %7.3f, e = %7.3f\n",
//.........这里部分代码省略.........
示例12: main
main(int argc,
char **argv)
{
l_int32 i, n, ws, hs, w, h, rval, gval, bval, order;
l_float32 *mat1, *mat2, *mat3;
l_float32 matd[9];
BOX *box, *boxt;
BOXA *boxa, *boxat, *boxa1, *boxa2, *boxa3, *boxa4, *boxa5;
PIX *pix, *pixs, *pixb, *pixc, *pixt, *pixt1, *pixt2, *pixt3;
PIXA *pixa;
static char mainName[] = "xformbox_reg";
/* ----------------------------------------------------------- *
* Test hash rendering in 3 modes *
* ----------------------------------------------------------- */
pixs = pixRead("feyn.tif");
box = boxCreate(461, 429, 1393, 342);
pixt1 = pixClipRectangle(pixs, box, NULL);
boxa = pixConnComp(pixt1, NULL, 8);
n = boxaGetCount(boxa);
pixt2 = pixConvertTo8(pixt1, 1);
pixt3 = pixConvertTo32(pixt1);
for (i = 0; i < n; i++) {
boxt = boxaGetBox(boxa, i, L_CLONE);
rval = (1413 * i) % 256;
gval = (4917 * i) % 256;
bval = (7341 * i) % 256;
pixRenderHashBox(pixt1, boxt, 8, 2, i % 4, 1, L_SET_PIXELS);
pixRenderHashBoxArb(pixt2, boxt, 7, 2, i % 4, 1, rval, gval, bval);
pixRenderHashBoxBlend(pixt3, boxt, 7, 2, i % 4, 1, rval, gval, bval,
0.5);
boxDestroy(&boxt);
}
pixDisplay(pixt1, 0, 0);
pixDisplay(pixt2, 0, 300);
pixDisplay(pixt3, 0, 570);
pixWrite("/tmp/junkpixt1.png", pixt1, IFF_PNG);
pixWrite("/tmp/junkpixt2.png", pixt2, IFF_PNG);
pixWrite("/tmp/junkpixt3.png", pixt3, IFF_PNG);
boxaDestroy(&boxa);
boxDestroy(&box);
pixDestroy(&pixs);
pixDestroy(&pixt1);
pixDestroy(&pixt2);
pixDestroy(&pixt3);
/* ----------------------------------------------------------- *
* Test box transforms with either translation or scaling *
* combined with rotation, using the simple 'ordered' *
* function. Show that the order of the operations does *
* not matter; different hashing schemes end up in the *
* identical boxes. *
* ----------------------------------------------------------- */
pix = pixRead("feyn.tif");
box = boxCreate(420, 360, 1500, 465);
pixt = pixClipRectangle(pix, box, NULL);
pixs = pixAddBorderGeneral(pixt, 0, 200, 0, 0, 0);
boxDestroy(&box);
pixDestroy(&pix);
pixDestroy(&pixt);
boxa = pixConnComp(pixs, NULL, 8);
n = boxaGetCount(boxa);
pixa = pixaCreate(0);
pixt = pixConvertTo32(pixs);
for (i = 0; i < 3; i++) {
if (i == 0)
order = L_TR_SC_RO;
else if (i == 1)
order = L_TR_RO_SC;
else
order = L_SC_TR_RO;
boxat = boxaTransformOrdered(boxa, SHIFTX_2, SHIFTY_2, 1.0, 1.0,
450, 250, ROTATION_2, order);
RenderTransformedBoxa(pixt, boxat, i);
boxaDestroy(&boxat);
}
pixSaveTiled(pixt, pixa, 1, 1, 30, 32);
pixDestroy(&pixt);
pixt = pixConvertTo32(pixs);
for (i = 0; i < 3; i++) {
if (i == 0)
order = L_RO_TR_SC;
else if (i == 1)
order = L_RO_SC_TR;
else
order = L_SC_RO_TR;
boxat = boxaTransformOrdered(boxa, SHIFTX_2, SHIFTY_2, 1.0, 1.0,
450, 250, ROTATION_2, order);
RenderTransformedBoxa(pixt, boxat, i + 4);
boxaDestroy(&boxat);
}
pixSaveTiled(pixt, pixa, 1, 1, 30, 0);
pixDestroy(&pixt);
pixt = pixConvertTo32(pixs);
for (i = 0; i < 3; i++) {
//.........这里部分代码省略.........
示例13: main
int main(int argc,
char **argv)
{
l_int32 i, j;
l_float32 f;
l_uint32 redval, greenval;
PIX *pixs, *pixd, *pix0, *pix1, *pix2;
static char mainName[] = "locminmax_reg";
if (argc != 1)
return ERROR_INT("syntax: locminmax_reg", mainName, 1);
pixs = pixCreate(500, 500, 8);
for (i = 0; i < 500; i++) {
for (j = 0; j < 500; j++) {
f = 128.0 + 26.3 * sin(0.0438 * (l_float32)i);
f += 33.4 * cos(0.0712 * (l_float32)i);
f += 18.6 * sin(0.0561 * (l_float32)j);
f += 23.6 * cos(0.0327 * (l_float32)j);
pixSetPixel(pixs, j, i, (l_int32)f);
}
}
pixDisplay(pixs, 0, 0);
pixWrite("/tmp/junkpattern.png", pixs, IFF_PNG);
startTimer();
/* pixSelectedLocalExtrema(pixs, 1, &pix1, &pix2); */
pixLocalExtrema(pixs, 0, 0, &pix1, &pix2);
fprintf(stderr, "Time for extrema: %7.3f\n", stopTimer());
composeRGBPixel(255, 0, 0, &redval);
composeRGBPixel(0, 255, 0, &greenval);
pixd = pixConvertTo32(pixs);
pixPaintThroughMask(pixd, pix2, 0, 0, greenval);
pixPaintThroughMask(pixd, pix1, 0, 0, redval);
pixDisplay(pixd, 510, 0);
pixWrite("/tmp/junkpixd.png", pixd, IFF_PNG);
pixDestroy(&pix1);
pixDestroy(&pix2);
pixDestroy(&pixs);
pixDestroy(&pixd);
pix0 = pixRead("karen8.jpg");
pixs = pixBlockconv(pix0, 10, 10);
pixDisplay(pixs, 0, 400);
pixWrite("/tmp/junkconv.png", pixs, IFF_PNG);
startTimer();
/* pixSelectedLocalExtrema(pixs, 1, &pix1, &pix2); */
pixLocalExtrema(pixs, 50, 100, &pix1, &pix2);
fprintf(stderr, "Time for extrema: %7.3f\n", stopTimer());
composeRGBPixel(255, 0, 0, &redval);
composeRGBPixel(0, 255, 0, &greenval);
pixd = pixConvertTo32(pixs);
pixPaintThroughMask(pixd, pix2, 0, 0, greenval);
pixPaintThroughMask(pixd, pix1, 0, 0, redval);
pixDisplay(pixd, 350, 400);
pixWrite("/tmp/junkpixd2.png", pixd, IFF_PNG);
pixDestroy(&pix0);
pixDestroy(&pix1);
pixDestroy(&pix2);
pixDestroy(&pixs);
pixDestroy(&pixd);
return 0;
}
示例14: main
main(int argc,
char **argv)
{
char *str;
l_int32 i, j, same, ok;
l_float32 sum, avediff, rmsdiff;
L_KERNEL *kel1, *kel2, *kel3, *kel4, *kelx, *kely;
BOX *box;
PIX *pix, *pixs, *pixb, *pixg, *pixr, *pixd, *pixp, *pixt;
PIX *pixt1, *pixt2, *pixt3;
PIXA *pixa;
SARRAY *sa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pixa = pixaCreate(0);
/* Test creating from a string */
kel1 = kernelCreateFromString(5, 5, 2, 2, kdatastr);
pixd = kernelDisplayInPix(kel1, 41, 2);
pixWrite("/tmp/pixkern.png", pixd, IFF_PNG);
regTestCheckFile(rp, "/tmp/pixkern.png"); /* 0 */
pixSaveTiled(pixd, pixa, 1, 1, 20, 8);
pixDestroy(&pixd);
kernelDestroy(&kel1);
/* Test read/write for kernel. Note that both get
* compared to the same golden file, which is
* overwritten with a copy of /tmp/kern2.kel */
kel1 = kernelCreateFromString(5, 5, 2, 2, kdatastr);
kernelWrite("/tmp/kern1.kel", kel1);
regTestCheckFile(rp, "/tmp/kern1.kel"); /* 1 */
kel2 = kernelRead("/tmp/kern1.kel");
kernelWrite("/tmp/kern2.kel", kel2);
regTestCheckFile(rp, "/tmp/kern2.kel"); /* 2 */
regTestCompareFiles(rp, 1, 2); /* 3 */
kernelDestroy(&kel1);
kernelDestroy(&kel2);
/* Test creating from a file */
sa = sarrayCreate(0);
sarrayAddString(sa, (char *)"# small 3x3 kernel", L_COPY);
sarrayAddString(sa, (char *)"3 5", L_COPY);
sarrayAddString(sa, (char *)"1 2", L_COPY);
sarrayAddString(sa, (char *)"20.5 50 80 50 20", L_COPY);
sarrayAddString(sa, (char *)"82. 120 180 120 80", L_COPY);
sarrayAddString(sa, (char *)"22.1 50 80 50 20", L_COPY);
str = sarrayToString(sa, 1);
l_binaryWrite("/tmp/kernfile.kel", "w", str, strlen(str));
kel2 = kernelCreateFromFile("/tmp/kernfile.kel");
pixd = kernelDisplayInPix(kel2, 41, 2);
pixSaveTiled(pixd, pixa, 1, 1, 20, 0);
pixWrite("/tmp/ker1.png", pixd, IFF_PNG);
regTestCheckFile(rp, "/tmp/ker1.png"); /* 4 */
pixDestroy(&pixd);
sarrayDestroy(&sa);
lept_free(str);
kernelDestroy(&kel2);
/* Test creating from a pix */
pixt = pixCreate(5, 3, 8);
pixSetPixel(pixt, 0, 0, 20);
pixSetPixel(pixt, 1, 0, 50);
pixSetPixel(pixt, 2, 0, 80);
pixSetPixel(pixt, 3, 0, 50);
pixSetPixel(pixt, 4, 0, 20);
pixSetPixel(pixt, 0, 1, 80);
pixSetPixel(pixt, 1, 1, 120);
pixSetPixel(pixt, 2, 1, 180);
pixSetPixel(pixt, 3, 1, 120);
pixSetPixel(pixt, 4, 1, 80);
pixSetPixel(pixt, 0, 0, 20);
pixSetPixel(pixt, 1, 2, 50);
pixSetPixel(pixt, 2, 2, 80);
pixSetPixel(pixt, 3, 2, 50);
pixSetPixel(pixt, 4, 2, 20);
kel3 = kernelCreateFromPix(pixt, 1, 2);
pixd = kernelDisplayInPix(kel3, 41, 2);
pixSaveTiled(pixd, pixa, 1, 0, 20, 0);
pixWrite("/tmp/ker2.png", pixd, IFF_PNG);
regTestCheckFile(rp, "/tmp/ker2.png"); /* 5 */
pixDestroy(&pixd);
pixDestroy(&pixt);
kernelDestroy(&kel3);
/* Test convolution with kel1 */
pixs = pixRead("test24.jpg");
pixg = pixScaleRGBToGrayFast(pixs, 3, COLOR_GREEN);
pixSaveTiled(pixg, pixa, 1, 1, 20, 0);
kel1 = kernelCreateFromString(5, 5, 2, 2, kdatastr);
pixd = pixConvolve(pixg, kel1, 8, 1);
pixSaveTiled(pixd, pixa, 1, 0, 20, 0);
pixWrite("/tmp/ker3.png", pixd, IFF_PNG);
regTestCheckFile(rp, "/tmp/ker3.png"); /* 6 */
pixDestroy(&pixs);
pixDestroy(&pixg);
pixDestroy(&pixd);
kernelDestroy(&kel1);
//.........这里部分代码省略.........
示例15: main
int main(int argc,
char **argv)
{
l_int32 i, w, h;
l_float32 factor, scale;
BOX *box;
FILE *fp1;
PIX *pixs, *pixt;
PIXA *pixa;
SARRAY *sa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
factor = 0.95;
/* Uncompressed PS with scaling but centered on the page */
pixs = pixRead("feyn-fract.tif");
pixGetDimensions(pixs, &w, &h, NULL);
scale = L_MIN(factor * 2550 / w, factor * 3300 / h);
fp1 = lept_fopen("/tmp/regout/psio0.ps", "wb+");
pixWriteStreamPS(fp1, pixs, NULL, 300, scale);
lept_fclose(fp1);
regTestCheckFile(rp, "/tmp/regout/psio0.ps"); /* 0 */
pixDestroy(&pixs);
/* Uncompressed PS with scaling, with LL corner at (1500, 1500) mils */
pixs = pixRead("weasel4.11c.png");
pixGetDimensions(pixs, &w, &h, NULL);
scale = L_MIN(factor * 2550 / w, factor * 3300 / h);
box = boxCreate(1500, 1500, (l_int32)(1000 * scale * w / 300),
(l_int32)(1000 * scale * h / 300));
fp1 = lept_fopen("/tmp/regout/psio1.ps", "wb+");
pixWriteStreamPS(fp1, pixs, box, 300, 1.0);
lept_fclose(fp1);
regTestCheckFile(rp, "/tmp/regout/psio1.ps"); /* 1 */
boxDestroy(&box);
pixDestroy(&pixs);
/* DCT compressed PS with LL corner at (300, 1000) pixels */
pixs = pixRead("marge.jpg");
pixt = pixConvertTo32(pixs);
pixWrite("/tmp/regout/psio2.jpg", pixt, IFF_JFIF_JPEG);
convertJpegToPS("/tmp/regout/psio2.jpg", "/tmp/regout/psio3.ps",
"w", 300, 1000, 0, 4.0, 1, 1);
regTestCheckFile(rp, "/tmp/regout/psio2.jpg"); /* 2 */
regTestCheckFile(rp, "/tmp/regout/psio3.ps"); /* 3 */
pixDestroy(&pixt);
pixDestroy(&pixs);
/* For each page, apply tiff g4 image first; then jpeg or png over it */
convertG4ToPS("feyn.tif", "/tmp/regout/psio4.ps", "w",
0, 0, 0, 1.0, 1, 1, 0);
convertJpegToPS("marge.jpg", "/tmp/regout/psio4.ps",
"a", 500, 100, 300, 2.0, 1, 0);
convertFlateToPS("weasel4.11c.png", "/tmp/regout/psio4.ps",
"a", 300, 400, 300, 6.0, 1, 0);
convertJpegToPS("marge.jpg", "/tmp/regout/psio4.ps",
"a", 100, 800, 300, 1.5, 1, 1);
convertG4ToPS("feyn.tif", "/tmp/regout/psio4.ps",
"a", 0, 0, 0, 1.0, 2, 1, 0);
convertJpegToPS("marge.jpg", "/tmp/regout/psio4.ps",
"a", 1000, 700, 300, 2.0, 2, 0);
convertJpegToPS("marge.jpg", "/tmp/regout/psio4.ps",
"a", 100, 200, 300, 2.0, 2, 1);
convertG4ToPS("feyn.tif", "/tmp/regout/psio4.ps",
"a", 0, 0, 0, 1.0, 3, 1, 0);
convertJpegToPS("marge.jpg", "/tmp/regout/psio4.ps",
"a", 200, 200, 300, 2.0, 3, 0);
convertJpegToPS("marge.jpg", "/tmp/regout/psio4.ps",
"a", 200, 900, 300, 2.0, 3, 1);
regTestCheckFile(rp, "/tmp/regout/psio4.ps"); /* 4 */
/* Now apply jpeg first; then paint through a g4 mask.
* For gv, the first image with a b.b. determines the
* window size for the canvas, so we put down the largest
* image first. If we had rendered a small image first,
* gv and evince will not show the entire page. However, after
* conversion to pdf, everything works fine, regardless of the
* order in which images are placed into the PS. That is
* because the pdf interpreter is robust to bad hints, ignoring
* the page hints and computing the bounding box from the
* set of images rendered on the page.
*
* Concatenate several pages, with colormapped png, color
* jpeg and tiffg4 images (with the g4 image acting as a mask
* that we're painting black through. If the text layer
* is painted first, the following images occlude it; otherwise,
* the images remain in the background of the text. */
pixs = pixRead("wyom.jpg");
pixt = pixScaleToSize(pixs, 2528, 3300);
pixWrite("/tmp/regout/psio5.jpg", pixt, IFF_JFIF_JPEG);
pixDestroy(&pixs);
pixDestroy(&pixt);
convertJpegToPS("/tmp/regout/psio5.jpg", "/tmp/regout/psio5.ps",
"w", 0, 0, 300, 1.0, 1, 0);
convertFlateToPS("weasel8.240c.png", "/tmp/regout/psio5.ps",
//.........这里部分代码省略.........