l_int32 main(int argc, char **argv) { l_int32 ret, i, n, similar, x1, y1, val1, val2, val3, val4; l_float32 minave, minave2, maxave, fract; NUMA *na1, *na2, *na3, *na4, *na5, *na6; NUMAA *naa; PIX *pixs, *pix1, *pix2, *pix3, *pix4; L_REGPARAMS *rp; if (regTestSetup(argc, argv, &rp)) return 1; pixs = pixRead("feyn.tif"); pix1 = pixScaleToGray6(pixs); pixDisplayWithTitle(pix1, 100, 600, NULL, rp->display); /* Find averages of min and max along about 120 horizontal lines */ fprintf(stderr, "Ignore the following 12 error messages:\n"); na1 = numaCreate(0); na3 = numaCreate(0); for (y1 = 40; y1 < 575; y1 += 5) { ret = pixMinMaxNearLine(pix1, 20, y1, 400, y1, 5, L_SCAN_BOTH, NULL, NULL, &minave, &maxave); if (!ret) { numaAddNumber(na1, (l_int32)minave); numaAddNumber(na3, (l_int32)maxave); if (rp->display) fprintf(stderr, "y = %d: minave = %d, maxave = %d\n", y1, (l_int32)minave, (l_int32)maxave); } } /* Find averages along about 120 vertical lines. We've rotated * the image by 90 degrees, so the results should be nearly * identical to the first set. Also generate a single-sided * scan (L_SCAN_NEGATIVE) for comparison with the double-sided scans. */ pix2 = pixRotateOrth(pix1, 3); pixDisplayWithTitle(pix2, 600, 600, NULL, rp->display); na2 = numaCreate(0); na4 = numaCreate(0); na5 = numaCreate(0); for (x1 = 40; x1 < 575; x1 += 5) { ret = pixMinMaxNearLine(pix2, x1, 20, x1, 400, 5, L_SCAN_BOTH, NULL, NULL, &minave, &maxave); pixMinMaxNearLine(pix2, x1, 20, x1, 400, 5, L_SCAN_NEGATIVE, NULL, NULL, &minave2, NULL); if (!ret) { numaAddNumber(na2, (l_int32)minave); numaAddNumber(na4, (l_int32)maxave); numaAddNumber(na5, (l_int32)minave2); if (rp->display) fprintf(stderr, "x = %d: minave = %d, minave2 = %d, maxave = %d\n", x1, (l_int32)minave, (l_int32)minave2, (l_int32)maxave); } } numaSimilar(na1, na2, 3.0, &similar); /* should be TRUE */ regTestCompareValues(rp, similar, 1, 0); /* 0 */ numaSimilar(na3, na4, 1.0, &similar); /* should be TRUE */ regTestCompareValues(rp, similar, 1, 0); /* 1 */ numaWrite("/tmp/lept/regout/na1.na", na1); numaWrite("/tmp/lept/regout/na2.na", na2); numaWrite("/tmp/lept/regout/na3.na", na3); numaWrite("/tmp/lept/regout/na4.na", na4); numaWrite("/tmp/lept/regout/na5.na", na5); regTestCheckFile(rp, "/tmp/lept/regout/na1.na"); /* 2 */ regTestCheckFile(rp, "/tmp/lept/regout/na2.na"); /* 3 */ regTestCheckFile(rp, "/tmp/lept/regout/na3.na"); /* 4 */ regTestCheckFile(rp, "/tmp/lept/regout/na4.na"); /* 5 */ regTestCheckFile(rp, "/tmp/lept/regout/na5.na"); /* 6 */ /* Plot the average minimums for the 3 cases */ naa = numaaCreate(3); numaaAddNuma(naa, na1, L_INSERT); /* portrait, double-sided */ numaaAddNuma(naa, na2, L_INSERT); /* landscape, double-sided */ numaaAddNuma(naa, na5, L_INSERT); /* landscape, single-sided */ gplotSimpleN(naa, GPLOT_PNG, "/tmp/lept/regout/nearline", "Average minimums along lines"); #if 0 #ifndef _WIN32 sleep(1); #else Sleep(1000); #endif /* _WIN32 */ #endif pix3 = pixRead("/tmp/lept/regout/nearline.png"); regTestWritePixAndCheck(rp, pix3, IFF_PNG); /* 7 */ pixDisplayWithTitle(pix3, 100, 100, NULL, rp->display); if (rp->display) { n = numaGetCount(na3); for (i = 0; i < n; i++) { numaGetIValue(na1, i, &val1); numaGetIValue(na2, i, &val2); numaGetIValue(na3, i, &val3); numaGetIValue(na4, i, &val4); fprintf(stderr, "val1 = %d, val2 = %d, diff = %d; " "val3 = %d, val4 = %d, diff = %d\n", val1, val2, L_ABS(val1 - val2), val3, val4, L_ABS(val3 - val4)); } } numaaDestroy(&naa); numaDestroy(&na3); numaDestroy(&na4); /* Plot minima along a single line, with different distances */ pixMinMaxNearLine(pix1, 20, 200, 400, 200, 2, L_SCAN_BOTH, &na1, NULL, NULL, NULL); pixMinMaxNearLine(pix1, 20, 200, 400, 200, 5, L_SCAN_BOTH, &na2, NULL, NULL, NULL); pixMinMaxNearLine(pix1, 20, 200, 400, 200, 15, L_SCAN_BOTH, &na3, NULL, NULL, NULL); numaWrite("/tmp/lept/regout/na6.na", na1); regTestCheckFile(rp, "/tmp/lept/regout/na6.na"); /* 8 */ n = numaGetCount(na1); fract = 100.0 / n; na4 = numaTransform(na1, 0.0, fract); na5 = numaTransform(na2, 0.0, fract); na6 = numaTransform(na3, 0.0, fract); numaDestroy(&na1); numaDestroy(&na2); numaDestroy(&na3); na1 = numaUniformSampling(na4, 100); na2 = numaUniformSampling(na5, 100); na3 = numaUniformSampling(na6, 100); naa = numaaCreate(3); numaaAddNuma(naa, na1, L_INSERT); numaaAddNuma(naa, na2, L_INSERT); numaaAddNuma(naa, na3, L_INSERT); gplotSimpleN(naa, GPLOT_PNG, "/tmp/lept/regout/nearline2", "Min along line"); pix4 = pixRead("/tmp/lept/regout/nearline2.png"); regTestWritePixAndCheck(rp, pix4, IFF_PNG); /* 9 */ pixDisplayWithTitle(pix4, 800, 100, NULL, rp->display); numaaDestroy(&naa); numaDestroy(&na4); numaDestroy(&na5); numaDestroy(&na6); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); pixDestroy(&pix4); pixDestroy(&pixs); return regTestCleanup(rp); }
int main(int argc, char **argv) { l_uint8 *data1, *data2; l_int32 i, n; size_t size1, size2; BOX *box; PIX *pix, *pix1, *pix2, *pix3; PIXA *pixa, *pixa1; PIXC *pixc, *pixc1, *pixc2; PIXAC *pixac, *pixac1, *pixac2; L_REGPARAMS *rp; SARRAY *sa; if (regTestSetup(argc, argv, &rp)) return 1; lept_mkdir("lept/comp"); pixac = pixacompCreate(1); pixa = pixaCreate(0); /* --- Read in the images --- */ pix1 = pixRead("marge.jpg"); pixc1 = pixcompCreateFromPix(pix1, IFF_JFIF_JPEG); pix2 = pixCreateFromPixcomp(pixc1); pixc2 = pixcompCreateFromPix(pix2, IFF_JFIF_JPEG); pix3 = pixCreateFromPixcomp(pixc2); regTestWritePixAndCheck(rp, pix3, IFF_JFIF_JPEG); /* 0 */ pixSaveTiledOutline(pix3, pixa, 1.0, 1, 30, 2, 32); pixacompAddPix(pixac, pix1, IFF_DEFAULT); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); pixcompDestroy(&pixc1); pixcompDestroy(&pixc2); pix = pixRead("feyn.tif"); pix1 = pixScaleToGray6(pix); pixc1 = pixcompCreateFromPix(pix1, IFF_JFIF_JPEG); pix2 = pixCreateFromPixcomp(pixc1); pixc2 = pixcompCreateFromPix(pix2, IFF_JFIF_JPEG); pix3 = pixCreateFromPixcomp(pixc2); regTestWritePixAndCheck(rp, pix3, IFF_JFIF_JPEG); /* 1 */ pixSaveTiledOutline(pix3, pixa, 1.0, 1, 30, 2, 32); pixacompAddPix(pixac, pix1, IFF_DEFAULT); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); pixcompDestroy(&pixc1); pixcompDestroy(&pixc2); box = boxCreate(1144, 611, 690, 180); pix1 = pixClipRectangle(pix, box, NULL); pixc1 = pixcompCreateFromPix(pix1, IFF_TIFF_G4); pix2 = pixCreateFromPixcomp(pixc1); pixc2 = pixcompCreateFromPix(pix2, IFF_TIFF_G4); pix3 = pixCreateFromPixcomp(pixc2); regTestWritePixAndCheck(rp, pix3, IFF_TIFF_G4); /* 2 */ pixSaveTiledOutline(pix3, pixa, 1.0, 0, 30, 2, 32); pixacompAddPix(pixac, pix1, IFF_DEFAULT); boxDestroy(&box); pixDestroy(&pix); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); pixcompDestroy(&pixc1); pixcompDestroy(&pixc2); pix1 = pixRead("weasel4.11c.png"); pixc1 = pixcompCreateFromPix(pix1, IFF_PNG); pix2 = pixCreateFromPixcomp(pixc1); pixc2 = pixcompCreateFromPix(pix2, IFF_PNG); pix3 = pixCreateFromPixcomp(pixc2); regTestWritePixAndCheck(rp, pix3, IFF_PNG); /* 3 */ pixSaveTiledOutline(pix3, pixa, 1.0, 0, 30, 2, 32); pixacompAddPix(pixac, pix1, IFF_DEFAULT); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pix3); pixcompDestroy(&pixc1); pixcompDestroy(&pixc2); /* --- Extract formatting info from compressed strings --- */ for (i = 0; i < 4; i++) { pixc = pixacompGetPixcomp(pixac, i, L_NOCOPY); get_format_data(i, pixc->data, pixc->size); } /* Save a tiled composite from the pixa */ pix1 = pixaDisplayTiledAndScaled(pixa, 32, 400, 4, 0, 20, 2); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 4 */ pixDestroy(&pix1); /* Convert the pixac --> pixa and save a tiled composite */ pixa1 = pixaCreateFromPixacomp(pixac, L_COPY); pix1 = pixaDisplayTiledAndScaled(pixa1, 32, 400, 4, 0, 20, 2); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 5 */ pixaDestroy(&pixa1); pixDestroy(&pix1); /* Make a pixacomp from files, and join */ sa = sarrayCreate(0); for (i = 0; i < 6; i++) sarrayAddString(sa, (char *)fnames[i], L_COPY); pixac1 = pixacompCreateFromSA(sa, IFF_DEFAULT); pixacompJoin(pixac1, pixac, 0, -1); pixa1 = pixaCreateFromPixacomp(pixac1, L_COPY); pix1 = pixaDisplayTiledAndScaled(pixa1, 32, 250, 10, 0, 20, 2); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 6 */ pixacompDestroy(&pixac1); pixaDestroy(&pixa1); pixDestroy(&pix1); sarrayDestroy(&sa); /* Test serialized I/O */ pixacompWrite("/tmp/lept/comp/file1.pac", pixac); regTestCheckFile(rp, "/tmp/lept/comp/file1.pac"); /* 7 */ pixac1 = pixacompRead("/tmp/lept/comp/file1.pac"); pixacompWrite("/tmp/lept/comp/file2.pac", pixac1); regTestCheckFile(rp, "/tmp/lept/comp/file2.pac"); /* 8 */ regTestCompareFiles(rp, 7, 8); /* 9 */ pixac2 = pixacompRead("/tmp/lept/comp/file2.pac"); pixa1 = pixaCreateFromPixacomp(pixac2, L_COPY); pix1 = pixaDisplayTiledAndScaled(pixa1, 32, 250, 4, 0, 20, 2); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 10 */ pixacompDestroy(&pixac1); pixacompDestroy(&pixac2); pixaDestroy(&pixa1); pixDestroy(&pix1); /* Test serialized pixacomp I/O to and from memory */ pixacompWriteMem(&data1, &size1, pixac); pixac1 = pixacompReadMem(data1, size1); pixacompWriteMem(&data2, &size2, pixac1); pixac2 = pixacompReadMem(data2, size2); pixacompWrite("/tmp/lept/comp/file3.pac", pixac1); regTestCheckFile(rp, "/tmp/lept/comp/file3.pac"); /* 11 */ pixacompWrite("/tmp/lept/comp/file4.pac", pixac2); regTestCheckFile(rp, "/tmp/lept/comp/file4.pac"); /* 12 */ regTestCompareFiles(rp, 11, 12); /* 13 */ pixacompDestroy(&pixac1); pixacompDestroy(&pixac2); lept_free(data1); lept_free(data2); pixaDestroy(&pixa); pixacompDestroy(&pixac); return regTestCleanup(rp); }
int main(int argc, char **argv) { char bufname[256]; l_int32 i, w, h; l_float32 *mat1, *mat2, *mat3, *mat1i, *mat2i, *mat3i, *matdinv; l_float32 matd[9], matdi[9]; BOXA *boxa, *boxa2; PIX *pix, *pixs, *pixb, *pixg, *pixc, *pixcs; PIX *pixd, *pix1, *pix2, *pix3; PIXA *pixa; PTA *ptas, *ptad; L_REGPARAMS *rp; if (regTestSetup(argc, argv, &rp)) return 1; pix = pixRead("feyn.tif"); pixs = pixScale(pix, 0.22, 0.22); pixDestroy(&pix); #if ALL /* Test invertability of sequential. */ fprintf(stderr, "Test invertability of sequential\n"); pixa = pixaCreate(0); for (i = 0; i < 3; i++) { pixb = pixAddBorder(pixs, ADDED_BORDER_PIXELS, 0); MakePtas(i, &ptas, &ptad); pix1 = pixAffineSequential(pixb, ptad, ptas, 0, 0); regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 0,3,6 */ pixaAddPix(pixa, pix1, L_INSERT); pix2 = pixAffineSequential(pix1, ptas, ptad, 0, 0); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 1,4,7 */ pixaAddPix(pixa, pix2, L_INSERT); pixd = pixRemoveBorder(pix2, ADDED_BORDER_PIXELS); pixXor(pixd, pixd, pixs); regTestWritePixAndCheck(rp, pixd, IFF_PNG); /* 2,5,8 */ pixaAddPix(pixa, pixd, L_INSERT); pixDestroy(&pixb); ptaDestroy(&ptas); ptaDestroy(&ptad); } pix1 = pixaDisplayTiledInColumns(pixa, 3, 1.0, 20, 3); pix2 = pixScaleToGray(pix1, 0.2); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 9 */ pixDisplayWithTitle(pix2, 0, 100, NULL, rp->display); pixDestroy(&pix1); pixDestroy(&pix2); pixaDestroy(&pixa); #endif #if ALL /* Test invertability of sampling */ fprintf(stderr, "Test invertability of sampling\n"); pixa = pixaCreate(0); for (i = 0; i < 3; i++) { pixb = pixAddBorder(pixs, ADDED_BORDER_PIXELS, 0); MakePtas(i, &ptas, &ptad); pix1 = pixAffineSampledPta(pixb, ptad, ptas, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 10,13,16 */ pixaAddPix(pixa, pix1, L_INSERT); pix2 = pixAffineSampledPta(pix1, ptas, ptad, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 11,14,17 */ pixaAddPix(pixa, pix2, L_INSERT); pixd = pixRemoveBorder(pix2, ADDED_BORDER_PIXELS); pixXor(pixd, pixd, pixs); regTestWritePixAndCheck(rp, pixd, IFF_PNG); /* 12,15,18 */ pixaAddPix(pixa, pixd, L_INSERT); pixDestroy(&pixb); ptaDestroy(&ptas); ptaDestroy(&ptad); } pix1 = pixaDisplayTiledInColumns(pixa, 3, 1.0, 20, 3); pix2 = pixScaleToGray(pix1, 0.2); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 19 */ pixDisplayWithTitle(pix2, 200, 100, NULL, rp->display); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pixs); pixaDestroy(&pixa); #endif #if ALL /* Test invertability of interpolation on grayscale */ fprintf(stderr, "Test invertability of grayscale interpolation\n"); pix = pixRead("feyn.tif"); pixg = pixScaleToGray3(pix); pixDestroy(&pix); pixa = pixaCreate(0); for (i = 0; i < 3; i++) { pixb = pixAddBorder(pixg, ADDED_BORDER_PIXELS / 3, 255); MakePtas(i, &ptas, &ptad); pix1 = pixAffinePta(pixb, ptad, ptas, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 20,23,26 */ pixaAddPix(pixa, pix1, L_INSERT); pix2 = pixAffinePta(pix1, ptas, ptad, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); /* 21,24,27 */ pixaAddPix(pixa, pix2, L_INSERT); pixd = pixRemoveBorder(pix2, ADDED_BORDER_PIXELS / 3); pixXor(pixd, pixd, pixg); pixInvert(pixd, pixd); regTestWritePixAndCheck(rp, pixd, IFF_JFIF_JPEG); /* 22,25,28 */ pixaAddPix(pixa, pixd, L_INSERT); pixDestroy(&pixb); ptaDestroy(&ptas); ptaDestroy(&ptad); } pix1 = pixaDisplayTiledInColumns(pixa, 3, 1.0, 20, 3); pix2 = pixScale(pix1, 0.2, 0.2); regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); /* 29 */ pixDisplayWithTitle(pix2, 400, 100, NULL, rp->display); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pixg); pixaDestroy(&pixa); #endif #if ALL /* Test invertability of interpolation on color */ fprintf(stderr, "Test invertability of color interpolation\n"); pixa = pixaCreate(0); pixc = pixRead("test24.jpg"); pixcs = pixScale(pixc, 0.3, 0.3); for (i = 0; i < 3; i++) { pixb = pixAddBorder(pixcs, ADDED_BORDER_PIXELS / 4, 0xffffff00); MakePtas(i, &ptas, &ptad); pix1 = pixAffinePta(pixb, ptad, ptas, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 30,33,36 */ pixaAddPix(pixa, pix1, L_INSERT); pix2 = pixAffinePta(pix1, ptas, ptad, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); /* 31,34,37 */ pixaAddPix(pixa, pix2, L_INSERT); pixd = pixRemoveBorder(pix2, ADDED_BORDER_PIXELS / 4); pixXor(pixd, pixd, pixcs); pixInvert(pixd, pixd); regTestWritePixAndCheck(rp, pixd, IFF_JFIF_JPEG); /* 32,35,38 */ pixaAddPix(pixa, pixd, L_INSERT); pixDestroy(&pixb); ptaDestroy(&ptas); ptaDestroy(&ptad); } pix1 = pixaDisplayTiledInColumns(pixa, 3, 1.0, 20, 3); pix2 = pixScale(pix1, 0.25, 0.25); regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); /* 39 */ pixDisplayWithTitle(pix2, 600, 100, NULL, rp->display); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pixc); pixaDestroy(&pixa); #endif #if ALL /* Comparison between sequential and sampling */ fprintf(stderr, "Compare sequential with sampling\n"); pix = pixRead("feyn.tif"); pixs = pixScale(pix, 0.22, 0.22); pixDestroy(&pix); MakePtas(3, &ptas, &ptad); pixa = pixaCreate(0); /* Use sequential transforms */ pix1 = pixAffineSequential(pixs, ptas, ptad, ADDED_BORDER_PIXELS, ADDED_BORDER_PIXELS); regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 40 */ pixaAddPix(pixa, pix1, L_INSERT); /* Use sampled transform */ pix2 = pixAffineSampledPta(pixs, ptas, ptad, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 41 */ pixaAddPix(pixa, pix2, L_COPY); /* Compare the results */ pixXor(pix2, pix2, pix1); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 42 */ pixaAddPix(pixa, pix2, L_INSERT); pix1 = pixaDisplayTiledInColumns(pixa, 3, 1.0, 20, 3); pix2 = pixScale(pix1, 0.5, 0.5); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 43 */ pixDisplayWithTitle(pix2, 800, 100, NULL, rp->display); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pixs); pixaDestroy(&pixa); ptaDestroy(&ptas); ptaDestroy(&ptad); #endif #if ALL /* Test with large distortion */ fprintf(stderr, "Test with large distortion\n"); MakePtas(4, &ptas, &ptad); pixa = pixaCreate(0); pix = pixRead("feyn.tif"); pixg = pixScaleToGray6(pix); pixDestroy(&pix); pix1 = pixAffineSequential(pixg, ptas, ptad, 0, 0); regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 44 */ pixaAddPix(pixa, pix1, L_COPY); pix2 = pixAffineSampledPta(pixg, ptas, ptad, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 45 */ pixaAddPix(pixa, pix2, L_COPY); pix3 = pixAffinePta(pixg, ptas, ptad, L_BRING_IN_WHITE); regTestWritePixAndCheck(rp, pix3, IFF_PNG); /* 46 */ pixaAddPix(pixa, pix3, L_INSERT); pixXor(pix1, pix1, pix2); pixInvert(pix1, pix1); regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 47 */ pixaAddPix(pixa, pix1, L_INSERT); pixXor(pix2, pix2, pix3); pixInvert(pix2, pix2); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 48 */ pixaAddPix(pixa, pix2, L_INSERT); pix1 = pixaDisplayTiledInColumns(pixa, 5, 1.0, 20, 3); pix2 = pixScale(pix1, 0.8, 0.8); regTestWritePixAndCheck(rp, pix2, IFF_PNG); /* 49 */ pixDisplayWithTitle(pix2, 1000, 100, NULL, rp->display); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pixg); pixaDestroy(&pixa); ptaDestroy(&ptas); ptaDestroy(&ptad); #endif #if ALL /* Set up pix and boxa */ fprintf(stderr, "Test affine transforms and inverses on pix and boxa\n"); pixa = pixaCreate(0); pix = pixRead("lucasta.1.300.tif"); pixTranslate(pix, pix, 70, 0, L_BRING_IN_WHITE); pix1 = pixCloseBrick(NULL, pix, 14, 5); pixOpenBrick(pix1, pix1, 1, 2); boxa = pixConnComp(pix1, NULL, 8); pixs = pixConvertTo32(pix); pixGetDimensions(pixs, &w, &h, NULL); pixc = pixCopy(NULL, pixs); RenderHashedBoxa(pixc, boxa, 113); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 50 */ pixaAddPix(pixa, pixc, L_INSERT); pixDestroy(&pix); pixDestroy(&pix1); /* Set up an affine transform in matd, and apply it to boxa */ mat1 = createMatrix2dTranslate(SHIFTX, SHIFTY); mat2 = createMatrix2dScale(SCALEX, SCALEY); mat3 = createMatrix2dRotate(w / 2, h / 2, ROTATION); l_productMat3(mat3, mat2, mat1, matd, 3); boxa2 = boxaAffineTransform(boxa, matd); /* Set up the inverse transform --> matdi */ mat1i = createMatrix2dTranslate(-SHIFTX, -SHIFTY); mat2i = createMatrix2dScale(1.0/ SCALEX, 1.0 / SCALEY); mat3i = createMatrix2dRotate(w / 2, h / 2, -ROTATION); l_productMat3(mat1i, mat2i, mat3i, matdi, 3); /* Invert the original affine transform --> matdinv */ affineInvertXform(matd, &matdinv); if (rp->display) { fprintf(stderr, " Affine transform, applied to boxa\n"); for (i = 0; i < 9; i++) { if (i && (i % 3 == 0)) fprintf(stderr, "\n"); fprintf(stderr, " %7.3f ", matd[i]); } fprintf(stderr, "\n Inverse transform, by composing inverse parts"); for (i = 0; i < 9; i++) { if (i % 3 == 0) fprintf(stderr, "\n"); fprintf(stderr, " %7.3f ", matdi[i]); } fprintf(stderr, "\n Inverse transform, by inverting affine xform"); for (i = 0; i < 6; i++) { if (i % 3 == 0) fprintf(stderr, "\n"); fprintf(stderr, " %7.3f ", matdinv[i]); } fprintf(stderr, "\n"); } /* Apply the inverted affine transform --> pixs */ pixd = pixAffine(pixs, matdinv, L_BRING_IN_WHITE); RenderHashedBoxa(pixd, boxa2, 513); regTestWritePixAndCheck(rp, pixd, IFF_PNG); /* 51 */ pixaAddPix(pixa, pixd, L_INSERT); pix1 = pixaDisplayTiledInColumns(pixa, 2, 1.0, 30, 2); regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 52 */ pixDisplayWithTitle(pix1, 1200, 100, NULL, rp->display); pixDestroy(&pix1); pixaDestroy(&pixa); pixDestroy(&pixs); boxaDestroy(&boxa); boxaDestroy(&boxa2); lept_free(mat1); lept_free(mat2); lept_free(mat3); lept_free(mat1i); lept_free(mat2i); lept_free(mat3i); lept_free(matdinv); #endif return regTestCleanup(rp); }
int main(int argc, char **argv) { l_int32 i; PIX *pixs, *pixc; PIXA *pixa; L_REGPARAMS *rp; if (regTestSetup(argc, argv, &rp)) return 1; /* Test 1 bpp */ fprintf(stderr, "\n-------------- Testing 1 bpp ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[0]); pixc = pixScale(pixs, 0.32, 0.32); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 0 */ pixSaveTiled(pixc, pixa, 1.0, 1, SPACE, 32); pixDestroy(&pixc); pixc = pixScaleToGray3(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 1 */ PixSave32(pixa, pixc); pixc = pixScaleToGray4(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 2 */ pixSaveTiled(pixc, pixa, 1.0, 1, SPACE, 32); pixDestroy(&pixc); pixc = pixScaleToGray6(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 3 */ PixSave32(pixa, pixc); pixc = pixScaleToGray8(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 4 */ PixSave32(pixa, pixc); pixc = pixScaleToGray16(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 5 */ PixSave32(pixa, pixc); pixDestroy(&pixs); PixaSaveDisplay(pixa, rp); /* 6 */ for (i = 1; i < 10; i++) { pixa = pixaCreate(0); AddScaledImages(pixa, image[i], WIDTH); PixaSaveDisplay(pixa, rp); /* 7 - 16 */ } /* Test 2 bpp without colormap */ fprintf(stderr, "\n-------------- Testing 2 bpp without cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[1]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 2.25, 2.25); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 17 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 18 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 19 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 20 */ pixDestroy(&pixs); /* Test 2 bpp with colormap */ fprintf(stderr, "\n-------------- Testing 2 bpp with cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[2]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 2.25, 2.25); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 21 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 22 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 23 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 24 */ pixDestroy(&pixs); /* Test 4 bpp without colormap */ fprintf(stderr, "\n-------------- Testing 4 bpp without cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[3]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 1.72, 1.72); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 25 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 26 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 27 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 28 */ pixDestroy(&pixs); /* Test 4 bpp with colormap */ fprintf(stderr, "\n-------------- Testing 4 bpp with cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[4]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 1.72, 1.72); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 29 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 30 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 31 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 32 */ pixDestroy(&pixs); /* Test 8 bpp without colormap */ fprintf(stderr, "\n-------------- Testing 8 bpp without cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[5]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 1.92, 1.92); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 33 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 34 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 35 */ PixSave32(pixa, pixc); pixDestroy(&pixs); pixs = pixRead("graytext.png"); pixc = pixScaleToSize(pixs, 0, 32); /* uses fast unsharp masking */ regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 36 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 37 */ pixDestroy(&pixs); /* Test 8 bpp with colormap */ fprintf(stderr, "\n-------------- Testing 8 bpp with cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[6]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 1.92, 1.92); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 38 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 39 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 40 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 41 */ pixDestroy(&pixs); /* Test 16 bpp */ fprintf(stderr, "\n-------------- Testing 16 bpp ------------\n"); pixa = pixaCreate(0); pixs = pixRead(image[7]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 1.92, 1.92); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 42 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 43 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 44 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 45 */ pixDestroy(&pixs); /* Test 32 bpp */ fprintf(stderr, "\n-------------- Testing 32 bpp ------------\n"); pixa = pixaCreate(0); pixs = pixRead(image[8]); pixSaveTiled(pixs, pixa, 1.0, 1, SPACE, 32); pixc = pixScale(pixs, 1.42, 1.42); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 46 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 47 */ PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); /* 48 */ PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); /* 49 */ pixDestroy(&pixs); return regTestCleanup(rp); }
main(int argc, char **argv) { PIX *pixs; l_int32 d; static char mainName[] = "scaletest2"; if (argc != 2) return ERROR_INT(" Syntax: scaletest2 filein", mainName, 1); if ((pixs = pixRead(argv[1])) == NULL) return ERROR_INT("pixs not made", mainName, 1); d = pixGetDepth(pixs); #if 1 /* Integer scale-to-gray functions */ if (d == 1) { PIX *pixd; pixd = pixScaleToGray2(pixs); pixWrite("/tmp/s2g_2x", pixd, IFF_PNG); pixDestroy(&pixd); pixd = pixScaleToGray3(pixs); pixWrite("/tmp/s2g_3x", pixd, IFF_PNG); pixDestroy(&pixd); pixd = pixScaleToGray4(pixs); pixWrite("/tmp/s2g_4x", pixd, IFF_PNG); pixDestroy(&pixd); pixd = pixScaleToGray6(pixs); pixWrite("/tmp/s2g_6x", pixd, IFF_PNG); pixDestroy(&pixd); pixd = pixScaleToGray8(pixs); pixWrite("/tmp/s2g_8x", pixd, IFF_PNG); pixDestroy(&pixd); pixd = pixScaleToGray16(pixs); pixWrite("/tmp/s2g_16x", pixd, IFF_PNG); pixDestroy(&pixd); } #endif #if 1 /* Various non-integer scale-to-gray, compared with * with different ways of getting similar results */ if (d == 1) { PIX *pixt, *pixd; pixd = pixScaleToGray8(pixs); pixWrite("/tmp/s2g_8.png", pixd, IFF_PNG); pixDestroy(&pixd); pixd = pixScaleToGray(pixs, 0.124); pixWrite("/tmp/s2g_124.png", pixd, IFF_PNG); pixDestroy(&pixd); pixd = pixScaleToGray(pixs, 0.284); pixWrite("/tmp/s2g_284.png", pixd, IFF_PNG); pixDestroy(&pixd); pixt = pixScaleToGray4(pixs); pixd = pixScaleBySampling(pixt, 284./250., 284./250.); pixWrite("/tmp/s2g_284.2.png", pixd, IFF_PNG); pixDestroy(&pixt); pixDestroy(&pixd); pixt = pixScaleToGray4(pixs); pixd = pixScaleGrayLI(pixt, 284./250., 284./250.); pixWrite("/tmp/s2g_284.3.png", pixd, IFF_PNG); pixDestroy(&pixt); pixDestroy(&pixd); pixt = pixScaleBinary(pixs, 284./250., 284./250.); pixd = pixScaleToGray4(pixt); pixWrite("/tmp/s2g_284.4.png", pixd, IFF_PNG); pixDestroy(&pixt); pixDestroy(&pixd); pixt = pixScaleToGray4(pixs); pixd = pixScaleGrayLI(pixt, 0.49, 0.49); pixWrite("/tmp/s2g_42.png", pixd, IFF_PNG); pixDestroy(&pixt); pixDestroy(&pixd); pixt = pixScaleToGray4(pixs); pixd = pixScaleSmooth(pixt, 0.49, 0.49); pixWrite("/tmp/s2g_4sm.png", pixd, IFF_PNG); pixDestroy(&pixt); pixDestroy(&pixd); pixt = pixScaleBinary(pixs, .16/.125, .16/.125); pixd = pixScaleToGray8(pixt); pixWrite("/tmp/s2g_16.png", pixd, IFF_PNG); pixDestroy(&pixt); pixDestroy(&pixd); pixd = pixScaleToGray(pixs, .16); pixWrite("/tmp/s2g_16.2.png", pixd, IFF_PNG); pixDestroy(&pixd); } #endif #if 1 /* Antialiased (smoothed) reduction, along with sharpening */ if (d != 1) { PIX *pixt1, *pixt2; startTimer(); pixt1 = pixScaleSmooth(pixs, 0.154, 0.154); fprintf(stderr, "fast scale: %5.3f sec\n", stopTimer()); pixDisplayWithTitle(pixt1, 0, 0, "smooth scaling", DISPLAY); pixWrite("/tmp/smooth1.png", pixt1, IFF_PNG); pixt2 = pixUnsharpMasking(pixt1, 1, 0.3); pixWrite("/tmp/smooth2.png", pixt2, IFF_PNG); pixDisplayWithTitle(pixt2, 200, 0, "sharp scaling", DISPLAY); pixDestroy(&pixt1); pixDestroy(&pixt2); } #endif #if 1 /* Test a large range of scale-to-gray reductions */ if (d == 1) { l_int32 i; l_float32 scale; PIX *pixd; for (i = 2; i < 15; i++) { scale = 1. / (l_float32)i; startTimer(); pixd = pixScaleToGray(pixs, scale); fprintf(stderr, "Time for scale %7.3f: %7.3f sec\n", scale, stopTimer()); pixDisplayWithTitle(pixd, 75 * i, 100, "scaletogray", DISPLAY); pixDestroy(&pixd); } for (i = 8; i < 14; i++) { scale = 1. / (l_float32)(2 * i); startTimer(); pixd = pixScaleToGray(pixs, scale); fprintf(stderr, "Time for scale %7.3f: %7.3f sec\n", scale, stopTimer()); pixDisplayWithTitle(pixd, 100 * i, 600, "scaletogray", DISPLAY); pixDestroy(&pixd); } } #endif #if 1 /* Test the same range of scale-to-gray mipmap reductions */ if (d == 1) { l_int32 i; l_float32 scale; PIX *pixd; for (i = 2; i < 15; i++) { scale = 1. / (l_float32)i; startTimer(); pixd = pixScaleToGrayMipmap(pixs, scale); fprintf(stderr, "Time for scale %7.3f: %7.3f sec\n", scale, stopTimer()); pixDisplayWithTitle(pixd, 75 * i, 100, "scale mipmap", DISPLAY); pixDestroy(&pixd); } for (i = 8; i < 12; i++) { scale = 1. / (l_float32)(2 * i); startTimer(); pixd = pixScaleToGrayMipmap(pixs, scale); fprintf(stderr, "Time for scale %7.3f: %7.3f sec\n", scale, stopTimer()); pixDisplayWithTitle(pixd, 100 * i, 600, "scale mipmap", DISPLAY); pixDestroy(&pixd); } } #endif #if 1 /* Test several methods for antialiased reduction, * along with sharpening */ if (d != 1) { PIX *pixt1, *pixt2, *pixt3, *pixt4, *pixt5, *pixt6, *pixt7; l_float32 SCALING = 0.27; l_int32 SIZE = 7; l_int32 smooth; l_float32 FRACT = 1.0; smooth = SIZE / 2; startTimer(); pixt1 = pixScaleSmooth(pixs, SCALING, SCALING); fprintf(stderr, "fast scale: %5.3f sec\n", stopTimer()); pixDisplayWithTitle(pixt1, 0, 0, "smooth scaling", DISPLAY); pixWrite("/tmp/sm_1.png", pixt1, IFF_PNG); pixt2 = pixUnsharpMasking(pixt1, 1, 0.3); pixDisplayWithTitle(pixt2, 150, 0, "sharpened scaling", DISPLAY); startTimer(); pixt3 = pixBlockconv(pixs, smooth, smooth); pixt4 = pixScaleBySampling(pixt3, SCALING, SCALING); fprintf(stderr, "slow scale: %5.3f sec\n", stopTimer()); pixDisplayWithTitle(pixt4, 200, 200, "sampled scaling", DISPLAY); pixWrite("/tmp/sm_2.png", pixt4, IFF_PNG); startTimer(); pixt5 = pixUnsharpMasking(pixs, smooth, FRACT); pixt6 = pixBlockconv(pixt5, smooth, smooth); pixt7 = pixScaleBySampling(pixt6, SCALING, SCALING); fprintf(stderr, "very slow scale + sharp: %5.3f sec\n", stopTimer()); pixDisplayWithTitle(pixt7, 500, 200, "sampled scaling", DISPLAY); pixWrite("/tmp/sm_3.jpg", pixt7, IFF_JFIF_JPEG); pixDestroy(&pixt1); pixDestroy(&pixt2); pixDestroy(&pixt3); pixDestroy(&pixt4); pixDestroy(&pixt5); pixDestroy(&pixt6); pixDestroy(&pixt7); } #endif #if 1 /* Test the color scaling function, comparing the * special case of scaling factor 2.0 with the * general case. */ if (d == 32) { PIX *pix1, *pix2, *pixd; NUMA *nar, *nag, *nab, *naseq; GPLOT *gplot; startTimer(); pix1 = pixScaleColorLI(pixs, 2.00001, 2.0); fprintf(stderr, " Time with regular LI: %7.3f\n", stopTimer()); pixWrite("/tmp/color1.jpg", pix1, IFF_JFIF_JPEG); startTimer(); pix2 = pixScaleColorLI(pixs, 2.0, 2.0); fprintf(stderr, " Time with 2x LI: %7.3f\n", stopTimer()); pixWrite("/tmp/color2.jpg", pix2, IFF_JFIF_JPEG); pixd = pixAbsDifference(pix1, pix2); pixGetColorHistogram(pixd, 1, &nar, &nag, &nab); naseq = numaMakeSequence(0., 1., 256); gplot = gplotCreate("/tmp/plot_absdiff", GPLOT_X11, "Number vs diff", "diff", "number"); gplotSetScaling(gplot, GPLOT_LOG_SCALE_Y); gplotAddPlot(gplot, naseq, nar, GPLOT_POINTS, "red"); gplotAddPlot(gplot, naseq, nag, GPLOT_POINTS, "green"); gplotAddPlot(gplot, naseq, nab, GPLOT_POINTS, "blue"); gplotMakeOutput(gplot); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pixd); numaDestroy(&naseq); numaDestroy(&nar); numaDestroy(&nag); numaDestroy(&nab); gplotDestroy(&gplot); } #endif #if 1 /* Test the gray LI scaling function, comparing the * special cases of scaling factor 2.0 and 4.0 with the * general case */ if (d == 8 || d == 32) { PIX *pixt, *pix0, *pix1, *pix2, *pixd; NUMA *nagray, *naseq; GPLOT *gplot; if (d == 8) pixt = pixClone(pixs); else pixt = pixConvertRGBToGray(pixs, 0.33, 0.34, 0.33); pix0 = pixScaleGrayLI(pixt, 0.5, 0.5); #if 1 startTimer(); pix1 = pixScaleGrayLI(pix0, 2.00001, 2.0); fprintf(stderr, " Time with regular LI 2x: %7.3f\n", stopTimer()); startTimer(); pix2 = pixScaleGrayLI(pix0, 2.0, 2.0); fprintf(stderr, " Time with 2x LI: %7.3f\n", stopTimer()); #else startTimer(); pix1 = pixScaleGrayLI(pix0, 4.00001, 4.0); fprintf(stderr, " Time with regular LI 4x: %7.3f\n", stopTimer()); startTimer(); pix2 = pixScaleGrayLI(pix0, 4.0, 4.0); fprintf(stderr, " Time with 2x LI: %7.3f\n", stopTimer()); #endif pixWrite("/tmp/gray1", pix1, IFF_JFIF_JPEG); pixWrite("/tmp/gray2", pix2, IFF_JFIF_JPEG); pixd = pixAbsDifference(pix1, pix2); nagray = pixGetGrayHistogram(pixd, 1); naseq = numaMakeSequence(0., 1., 256); gplot = gplotCreate("/tmp/g_absdiff", GPLOT_X11, "Number vs diff", "diff", "number"); gplotSetScaling(gplot, GPLOT_LOG_SCALE_Y); gplotAddPlot(gplot, naseq, nagray, GPLOT_POINTS, "gray"); gplotMakeOutput(gplot); pixDestroy(&pixt); pixDestroy(&pix0); pixDestroy(&pix1); pixDestroy(&pix2); pixDestroy(&pixd); numaDestroy(&naseq); numaDestroy(&nagray); gplotDestroy(&gplot); } #endif pixDestroy(&pixs); return 0; }
main(int argc, char **argv) { l_int32 i; PIX *pixs, *pixc, *pixd; PIXA *pixa; L_REGPARAMS *rp; if (regTestSetup(argc, argv, &rp)) return 1; /* Test 1 bpp */ fprintf(stderr, "\n-------------- Testing 1 bpp ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[0]); pixc = pixScale(pixs, 0.32, 0.32); regTestWritePixAndCheck(rp, pixc, IFF_PNG); pixSaveTiled(pixc, pixa, 1, 1, SPACE, 32); pixDestroy(&pixc); pixc = pixScaleToGray3(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScaleToGray4(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); pixSaveTiled(pixc, pixa, 1, 1, SPACE, 32); pixDestroy(&pixc); pixc = pixScaleToGray6(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScaleToGray8(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScaleToGray16(pixs); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixDestroy(&pixs); PixaSaveDisplay(pixa, rp); for (i = 1; i < 10; i++) { pixa = pixaCreate(0); AddScaledImages(pixa, image[i], WIDTH); PixaSaveDisplay(pixa, rp); } /* Test 2 bpp without colormap */ fprintf(stderr, "\n-------------- Testing 2 bpp without cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[1]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 2.25, 2.25); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); /* Test 2 bpp with colormap */ fprintf(stderr, "\n-------------- Testing 2 bpp with cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[2]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 2.25, 2.25); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); /* Test 4 bpp without colormap */ fprintf(stderr, "\n-------------- Testing 4 bpp without cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[3]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 1.72, 1.72); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); /* Test 4 bpp with colormap */ fprintf(stderr, "\n-------------- Testing 4 bpp with cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[4]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 1.72, 1.72); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_PNG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); /* Test 8 bpp without colormap */ fprintf(stderr, "\n-------------- Testing 8 bpp without cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[5]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 1.92, 1.92); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); /* Test 8 bpp with colormap */ fprintf(stderr, "\n-------------- Testing 8 bpp with cmap ----------\n"); pixa = pixaCreate(0); pixs = pixRead(image[6]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 1.92, 1.92); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); /* Test 16 bpp */ fprintf(stderr, "\n-------------- Testing 16 bpp ------------\n"); pixa = pixaCreate(0); pixs = pixRead(image[7]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 1.92, 1.92); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); /* Test 32 bpp */ fprintf(stderr, "\n-------------- Testing 32 bpp ------------\n"); pixa = pixaCreate(0); pixs = pixRead(image[8]); pixSaveTiled(pixs, pixa, 1, 1, SPACE, 32); pixc = pixScale(pixs, 1.42, 1.42); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.85, 0.85); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); pixc = pixScale(pixs, 0.65, 0.65); regTestWritePixAndCheck(rp, pixc, IFF_JFIF_JPEG); PixSave32(pixa, pixc); PixaSaveDisplay(pixa, rp); pixDestroy(&pixs); return regTestCleanup(rp); }