From a45de8934ed85b630a444e836ebdaa5a5ead2df2 Mon Sep 17 00:00:00 2001 From: Dan Bloomberg Date: Sat, 10 Jun 2017 17:06:25 -0700 Subject: [PATCH] Added two regtests to the automated set * boxa1_reg * conversion_reg --- prog/Makefile.am | 16 +-- prog/alltests_reg.c | 2 + prog/boxa1_reg.c | 63 ++++----- prog/conversion_reg.c | 288 ++++++++++++++++++++++-------------------- 4 files changed, 193 insertions(+), 176 deletions(-) diff --git a/prog/Makefile.am b/prog/Makefile.am index dba486a59..8283b16c5 100644 --- a/prog/Makefile.am +++ b/prog/Makefile.am @@ -14,12 +14,12 @@ AUTO_REG_PROGS = adaptmap_reg affine_reg alphaops_reg \ alphaxform_reg baseline_reg bilateral2_reg \ bilinear_reg binarize_reg blackwhite_reg \ blend1_reg blend2_reg blend3_reg blend4_reg \ - ccthin1_reg ccthin2_reg cmapquant_reg \ - colorcontent_reg coloring_reg \ - colorize_reg colormask_reg \ - colormorph_reg colorquant_reg \ - colorseg_reg colorspace_reg compare_reg compfilter_reg \ - conncomp_reg convolve_reg dewarp_reg distance_reg \ + boxa1_reg ccthin1_reg ccthin2_reg cmapquant_reg \ + colorcontent_reg coloring_reg colorize_reg \ + colormask_reg colormorph_reg colorquant_reg \ + colorseg_reg colorspace_reg compare_reg \ + compfilter_reg conncomp_reg conversion_reg \ + convolve_reg dewarp_reg distance_reg \ dither_reg dna_reg dwamorph1_reg edge_reg enhance_reg \ expand_reg findcorners_reg findpattern_reg \ fpix1_reg fpix2_reg genfonts_reg \ @@ -58,9 +58,7 @@ endif MANUAL_REG_PROGS = alltests_reg adaptnorm_reg bilateral1_reg \ binmorph1_reg binmorph2_reg binmorph3_reg \ - binmorph4_reg binmorph5_reg \ - boxa1_reg boxa2_reg \ - colorize_reg conversion_reg \ + binmorph4_reg binmorph5_reg boxa2_reg \ dwamorph2_reg equal_reg extrema_reg \ fhmtauto_reg files_reg flipdetect_reg fmorphauto_reg \ grayfill_reg heap_reg locminmax_reg \ diff --git a/prog/alltests_reg.c b/prog/alltests_reg.c index 7bbbfb243..b07e2c55b 100644 --- a/prog/alltests_reg.c +++ b/prog/alltests_reg.c @@ -59,6 +59,7 @@ static const char *tests[] = { "blend2_reg", "blend3_reg", "blend4_reg", + "boxa1_reg", "ccthin1_reg", "ccthin2_reg", "cmapquant_reg", @@ -73,6 +74,7 @@ static const char *tests[] = { "compare_reg", "compfilter_reg", "conncomp_reg", + "conversion_reg", "convolve_reg", "dewarp_reg", "distance_reg", diff --git a/prog/boxa1_reg.c b/prog/boxa1_reg.c index ef5f155dd..cc848caf6 100644 --- a/prog/boxa1_reg.c +++ b/prog/boxa1_reg.c @@ -47,10 +47,10 @@ BOXA *boxa1, *boxa2, *boxa3; BOXAA *baa1, *baa2, *baa3; PIX *pix1, *pixdb; PIXA *pixa1, *pixa2; -static char mainName[] = "boxa1_reg"; +L_REGPARAMS *rp; - if (argc != 1) - return ERROR_INT(" Syntax: boxa1_reg", mainName, 1); + if (regTestSetup(argc, argv, &rp)) + return 1; lept_mkdir("lept/boxa"); @@ -69,30 +69,35 @@ static char mainName[] = "boxa1_reg"; box = boxCreate(117, 206, 26, 74); boxaAddBox(boxa1, box, L_INSERT); pix1 = DisplayBoxa(boxa1); - pixDisplay(pix1, 100, 100); + regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 0 */ + pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display); pixDestroy(&pix1); boxaCompareRegions(boxa1, boxa1, 100, &same, &diffarea, &diffxor, NULL); - fprintf(stderr, "same = %d, diffarea = %5.3f, diffxor = %5.3f\n", - same, diffarea, diffxor); + regTestCompareValues(rp, 1, same, 0.0); /* 1 */ + regTestCompareValues(rp, 0.0, diffarea, 0.0); /* 2 */ + regTestCompareValues(rp, 0.0, diffxor, 0.0); /* 3 */ boxa2 = boxaTransform(boxa1, -13, -13, 1.0, 1.0); boxaCompareRegions(boxa1, boxa2, 10, &same, &diffarea, &diffxor, NULL); - fprintf(stderr, "same = %d, diffarea = %5.3f, diffxor = %5.3f\n", - same, diffarea, diffxor); + regTestCompareValues(rp, 1, same, 0.0); /* 4 */ + regTestCompareValues(rp, 0.0, diffarea, 0.0); /* 5 */ + regTestCompareValues(rp, 0.0, diffxor, 0.0); /* 6 */ boxaDestroy(&boxa2); boxa2 = boxaReconcileEvenOddHeight(boxa1, L_ADJUST_TOP_AND_BOT, 6, L_ADJUST_CHOOSE_MIN, 1.0, 0); pix1 = DisplayBoxa(boxa2); - pixDisplay(pix1, 100, 500); + regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 7 */ + pixDisplayWithTitle(pix1, 200, 0, NULL, rp->display); pixDestroy(&pix1); boxaCompareRegions(boxa1, boxa2, 10, &same, &diffarea, &diffxor, &pixdb); - fprintf(stderr, "same = %d, diffarea = %5.3f, diffxor = %5.3f\n", - same, diffarea, diffxor); - pixDisplay(pixdb, 700, 100); - + regTestCompareValues(rp, 1, same, 0.0); /* 8 */ + regTestCompareValues(rp, 0.053, diffarea, 0.002); /* 9 */ + regTestCompareValues(rp, 0.240, diffxor, 0.002); /* 10 */ + regTestWritePixAndCheck(rp, pixdb, IFF_PNG); /* 11 */ + pixDisplayWithTitle(pixdb, 400, 0, NULL, rp->display); pixDestroy(&pixdb); boxaDestroy(&boxa1); boxaDestroy(&boxa2); @@ -106,8 +111,8 @@ static char mainName[] = "boxa1_reg"; scalefact = (l_float32)width / (l_float32)w; boxa3 = boxaTransform(boxa2, 0, 0, scalefact, scalefact); pix1 = boxaDisplayTiled(boxa3, NULL, 1500, 2, 1.0, 0, 3, 2); - pixDisplay(pix1, 0, 100); - pixWrite("/tmp/lept/boxa/pix1.png", pix1, IFF_PNG); + regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 12 */ + pixDisplayWithTitle(pix1, 600, 0, NULL, rp->display); pixDestroy(&pix1); boxaDestroy(&boxa1); boxaDestroy(&boxa2); @@ -122,8 +127,8 @@ static char mainName[] = "boxa1_reg"; scalefact = (l_float32)width / (l_float32)w; boxa3 = boxaTransform(boxa2, 0, 0, scalefact, scalefact); pix1 = boxaDisplayTiled(boxa3, NULL, 1500, 2, 1.0, 0, 3, 2); - pixDisplay(pix1, 500, 100); - pixWrite("/tmp/lept/boxa/pix2.png", pix1, IFF_PNG); + regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 13 */ + pixDisplayWithTitle(pix1, 800, 0, NULL, rp->display); pixDestroy(&pix1); boxaDestroy(&boxa1); boxaDestroy(&boxa2); @@ -138,8 +143,8 @@ static char mainName[] = "boxa1_reg"; scalefact = (l_float32)width / (l_float32)w; boxa3 = boxaTransform(boxa2, 0, 0, scalefact, scalefact); pix1 = boxaDisplayTiled(boxa3, NULL, 1500, 2, 1.0, 0, 3, 2); - pixDisplay(pix1, 1000, 100); - pixWrite("/tmp/lept/boxa/pix3.png", pix1, IFF_PNG); + regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 14 */ + pixDisplayWithTitle(pix1, 1000, 0, NULL, rp->display); pixDestroy(&pix1); boxaDestroy(&boxa1); boxaDestroy(&boxa2); @@ -154,16 +159,13 @@ static char mainName[] = "boxa1_reg"; boxaWrite("/tmp/lept/boxa/boxa2.ba", boxa2); filesAreIdentical("/tmp/lept/boxa/boxa1.ba", "/tmp/lept/boxa/boxa2.ba", &same); - if (same) - fprintf(stderr, "Good: boxes files are identical\n"); - else - fprintf(stderr, "Bad: boxes files differ\n"); + regTestCompareValues(rp, 1, same, 0.0); /* 15 */ boxaDestroy(&boxa1); boxaDestroy(&boxa2); lept_free(data1); lept_free(data2); - /* Test pixaDisplayBoxaa() */ + /* ----------- Test pixaDisplayBoxaa() ------------ */ pixa1 = pixaReadBoth("showboxes.pac"); baa1 = boxaaRead("showboxes1.baa"); baa2 = boxaaTranspose(baa1); @@ -178,15 +180,16 @@ static char mainName[] = "boxa1_reg"; boxaDestroy(&boxa2); if (!same) success = FALSE; } - if (success) - fprintf(stderr, "Good: transpose is reversible\n"); - else - fprintf(stderr, "Bad: transpose failed\n"); + /* Check that the transpose is reversible */ + regTestCompareValues(rp, 1, success, 0.0); /* 16 */ pixa2 = pixaDisplayBoxaa(pixa1, baa2, L_DRAW_RGB, 2); pix1 = pixaDisplayTiledInRows(pixa2, 32, 1400, 1.0, 0, 10, 0); - pixDisplay(pix1, 0, 600); + regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 17 */ + pixDisplayWithTitle(pix1, 0, 600, NULL, rp->display); fprintf(stderr, "Writing to: /tmp/lept/boxa/show.pdf\n"); + l_pdfSetDateAndVersion(FALSE); pixaConvertToPdf(pixa2, 75, 1.0, 0, 0, NULL, "/tmp/lept/boxa/show.pdf"); + regTestCheckFile(rp, "/tmp/lept/boxa/show.pdf"); /* 18 */ pixDestroy(&pix1); pixaDestroy(&pixa1); pixaDestroy(&pixa2); @@ -194,7 +197,7 @@ static char mainName[] = "boxa1_reg"; boxaaDestroy(&baa2); boxaaDestroy(&baa3); - return 0; + return regTestCleanup(rp); } diff --git a/prog/conversion_reg.c b/prog/conversion_reg.c index f3acd23fa..3b7a3b99c 100644 --- a/prog/conversion_reg.c +++ b/prog/conversion_reg.c @@ -27,12 +27,10 @@ /* * conversion_reg.c * - * Regression test (_reg) for depth conversion functions, + * Regression test for depth conversion functions, * including some of the octcube quantization. */ -#define DFLAG 1 - #include "allheaders.h" int main(int argc, @@ -42,13 +40,13 @@ char *errorstr; l_int32 same, error; PIX *pixs1, *pixs2, *pixs4, *pixs8, *pixs16, *pixs32; PIX *pixc2, *pixc4, *pixc8; -PIX *pixt1, *pixt2, *pixt3, *pixt4, *pixt5, *pixt6; +PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pix6; PIXCMAP *cmap; SARRAY *sa; -static char mainName[] = "convert_reg"; +L_REGPARAMS *rp; - if (argc != 1) - return ERROR_INT(" Syntax: convert_reg", mainName, 1); + if (regTestSetup(argc, argv, &rp)) + return 1; pixs1 = pixRead("test1.png"); pixs2 = pixRead("dreyfus2.png"); @@ -63,247 +61,263 @@ static char mainName[] = "convert_reg"; sa = sarrayCreate(0); /* Conversion: 1 bpp --> 8 bpp --> 1 bpp */ - pixt1 = pixConvertTo8(pixs1, FALSE); - pixt2 = pixThreshold8(pixt1, 1, 0, 0); - pixEqual(pixs1, pixt2, &same); + pix1 = pixConvertTo8(pixs1, FALSE); + pix2 = pixThreshold8(pix1, 1, 0, 0); + regTestComparePix(rp, pixs1, pix2); /* 0 */ + pixEqual(pixs1, pix2, &same); if (!same) { - pixDisplayWithTitle(pixs1, 100, 100, "1 bpp, no cmap", DFLAG); - pixDisplayWithTitle(pixt2, 500, 100, "1 bpp, no cmap", DFLAG); + pixDisplayWithTitle(pixs1, 100, 100, "1 bpp, no cmap", 1); + pixDisplayWithTitle(pix2, 500, 100, "1 bpp, no cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 1 bpp <==> 8 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 1 bpp <==> 8 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); + pixDestroy(&pix1); + pixDestroy(&pix2); /* Conversion: 2 bpp --> 8 bpp --> 2 bpp */ /* Conversion: 2 bpp cmap --> 8 bpp cmap --> 2 bpp cmap */ - pixt1 = pixRemoveColormap(pixs2, REMOVE_CMAP_TO_GRAYSCALE); - pixt2 = pixThreshold8(pixt1, 2, 4, 0); - pixt3 = pixConvertTo8(pixt2, FALSE); - pixt4 = pixThreshold8(pixt3, 2, 4, 0); - pixEqual(pixt2, pixt4, &same); + pix1 = pixRemoveColormap(pixs2, REMOVE_CMAP_TO_GRAYSCALE); + pix2 = pixThreshold8(pix1, 2, 4, 0); + pix3 = pixConvertTo8(pix2, FALSE); + pix4 = pixThreshold8(pix3, 2, 4, 0); + regTestComparePix(rp, pix2, pix4); /* 1 */ + pixEqual(pix2, pix4, &same); if (!same) { - pixDisplayWithTitle(pixt2, 100, 100, "2 bpp, no cmap", DFLAG); - pixDisplayWithTitle(pixt4, 500, 100, "2 bpp, no cmap", DFLAG); + pixDisplayWithTitle(pix2, 100, 100, "2 bpp, no cmap", 1); + pixDisplayWithTitle(pix4, 500, 100, "2 bpp, no cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 2 bpp <==> 8 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 2 bpp <==> 8 bpp\n"); - pixt5 = pixConvertTo8(pixs2, TRUE); - pixt6 = pixThreshold8(pixt5, 2, 4, 1); - pixEqual(pixs2, pixt6, &same); + pix5 = pixConvertTo8(pixs2, TRUE); + pix6 = pixThreshold8(pix5, 2, 4, 1); + regTestComparePix(rp, pixs2, pix6); /* 2 */ + pixEqual(pixs2, pix6, &same); if (!same) { - pixDisplayWithTitle(pixs2, 100, 100, "2 bpp, cmap", DFLAG); - pixDisplayWithTitle(pixt6, 500, 100, "2 bpp, cmap", DFLAG); + pixDisplayWithTitle(pixs2, 100, 100, "2 bpp, cmap", 1); + pixDisplayWithTitle(pix6, 500, 100, "2 bpp, cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 2 bpp <==> 8 bpp; cmap", L_COPY); } else fprintf(stderr, "OK: conversion 2 bpp <==> 8 bpp; cmap\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); - pixDestroy(&pixt3); - pixDestroy(&pixt4); - pixDestroy(&pixt5); - pixDestroy(&pixt6); + pixDestroy(&pix1); + pixDestroy(&pix2); + pixDestroy(&pix3); + pixDestroy(&pix4); + pixDestroy(&pix5); + pixDestroy(&pix6); /* Conversion: 4 bpp --> 8 bpp --> 4 bpp */ /* Conversion: 4 bpp cmap --> 8 bpp cmap --> 4 bpp cmap */ - pixt1 = pixRemoveColormap(pixs4, REMOVE_CMAP_TO_GRAYSCALE); - pixt2 = pixThreshold8(pixt1, 4, 16, 0); - pixt3 = pixConvertTo8(pixt2, FALSE); - pixt4 = pixThreshold8(pixt3, 4, 16, 0); - pixEqual(pixt2, pixt4, &same); + pix1 = pixRemoveColormap(pixs4, REMOVE_CMAP_TO_GRAYSCALE); + pix2 = pixThreshold8(pix1, 4, 16, 0); + pix3 = pixConvertTo8(pix2, FALSE); + pix4 = pixThreshold8(pix3, 4, 16, 0); + regTestComparePix(rp, pix2, pix4); /* 3 */ + pixEqual(pix2, pix4, &same); if (!same) { - pixDisplayWithTitle(pixt2, 100, 100, "4 bpp, no cmap", DFLAG); - pixDisplayWithTitle(pixt4, 500, 100, "4 bpp, no cmap", DFLAG); + pixDisplayWithTitle(pix2, 100, 100, "4 bpp, no cmap", 1); + pixDisplayWithTitle(pix4, 500, 100, "4 bpp, no cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 4 bpp <==> 8 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 4 bpp <==> 8 bpp\n"); - pixt5 = pixConvertTo8(pixs4, TRUE); - pixt6 = pixThreshold8(pixt5, 4, 16, 1); - pixEqual(pixs4, pixt6, &same); + pix5 = pixConvertTo8(pixs4, TRUE); + pix6 = pixThreshold8(pix5, 4, 16, 1); + regTestComparePix(rp, pixs4, pix6); /* 4 */ + pixEqual(pixs4, pix6, &same); if (!same) { - pixDisplayWithTitle(pixs4, 100, 100, "4 bpp, cmap", DFLAG); - pixDisplayWithTitle(pixt6, 500, 100, "4 bpp, cmap", DFLAG); + pixDisplayWithTitle(pixs4, 100, 100, "4 bpp, cmap", 1); + pixDisplayWithTitle(pix6, 500, 100, "4 bpp, cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 4 bpp <==> 8 bpp, cmap", L_COPY); } else fprintf(stderr, "OK: conversion 4 bpp <==> 8 bpp; cmap\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); - pixDestroy(&pixt3); - pixDestroy(&pixt4); - pixDestroy(&pixt5); - pixDestroy(&pixt6); + pixDestroy(&pix1); + pixDestroy(&pix2); + pixDestroy(&pix3); + pixDestroy(&pix4); + pixDestroy(&pix5); + pixDestroy(&pix6); /* Conversion: 2 bpp cmap --> 2 bpp --> 2 bpp cmap --> 2 bpp */ - pixt1 = pixRemoveColormap(pixs2, REMOVE_CMAP_TO_GRAYSCALE); - pixt2 = pixConvertGrayToColormap(pixt1); - pixt3 = pixRemoveColormap(pixt2, REMOVE_CMAP_TO_GRAYSCALE); - pixt4 = pixThresholdTo2bpp(pixt3, 4, 1); - pixEqual(pixt1, pixt4, &same); + pix1 = pixRemoveColormap(pixs2, REMOVE_CMAP_TO_GRAYSCALE); + pix2 = pixConvertGrayToColormap(pix1); + pix3 = pixRemoveColormap(pix2, REMOVE_CMAP_TO_GRAYSCALE); + pix4 = pixThresholdTo2bpp(pix3, 4, 1); + regTestComparePix(rp, pix1, pix4); /* 5 */ + pixEqual(pix1, pix4, &same); if (!same) { - pixDisplayWithTitle(pixs2, 100, 100, "2 bpp, cmap", DFLAG); - pixDisplayWithTitle(pixt4, 500, 100, "2 bpp, cmap", DFLAG); + pixDisplayWithTitle(pixs2, 100, 100, "2 bpp, cmap", 1); + pixDisplayWithTitle(pix4, 500, 100, "2 bpp, cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 2 bpp <==> 2 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 2 bpp <==> 2 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); - pixDestroy(&pixt3); - pixDestroy(&pixt4); + pixDestroy(&pix1); + pixDestroy(&pix2); + pixDestroy(&pix3); + pixDestroy(&pix4); /* Conversion: 4 bpp cmap --> 4 bpp --> 4 bpp cmap --> 4 bpp */ - pixt1 = pixRemoveColormap(pixs4, REMOVE_CMAP_TO_GRAYSCALE); - pixt2 = pixConvertGrayToColormap(pixt1); - pixt3 = pixRemoveColormap(pixt2, REMOVE_CMAP_TO_GRAYSCALE); - pixt4 = pixThresholdTo4bpp(pixt3, 16, 1); - pixEqual(pixt1, pixt4, &same); + pix1 = pixRemoveColormap(pixs4, REMOVE_CMAP_TO_GRAYSCALE); + pix2 = pixConvertGrayToColormap(pix1); + pix3 = pixRemoveColormap(pix2, REMOVE_CMAP_TO_GRAYSCALE); + pix4 = pixThresholdTo4bpp(pix3, 16, 1); + regTestComparePix(rp, pix1, pix4); /* 6 */ + pixEqual(pix1, pix4, &same); if (!same) { - pixDisplayWithTitle(pixs4, 100, 100, "4 bpp, cmap", DFLAG); - pixDisplayWithTitle(pixt4, 500, 100, "4 bpp, cmap", DFLAG); + pixDisplayWithTitle(pixs4, 100, 100, "4 bpp, cmap", 1); + pixDisplayWithTitle(pix4, 500, 100, "4 bpp, cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 4 bpp <==> 4 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 4 bpp <==> 4 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); - pixDestroy(&pixt3); - pixDestroy(&pixt4); + pixDestroy(&pix1); + pixDestroy(&pix2); + pixDestroy(&pix3); + pixDestroy(&pix4); /* Conversion: 8 bpp --> 8 bpp cmap --> 8 bpp */ - pixt1 = pixConvertTo8(pixs8, TRUE); - pixt2 = pixConvertTo8(pixt1, FALSE); - pixEqual(pixs8, pixt2, &same); + pix1 = pixConvertTo8(pixs8, TRUE); + pix2 = pixConvertTo8(pix1, FALSE); + regTestComparePix(rp, pixs8, pix2); /* 7 */ + pixEqual(pixs8, pix2, &same); if (!same) { - pixDisplayWithTitle(pixt1, 100, 100, "8 bpp, cmap", DFLAG); - pixDisplayWithTitle(pixt2, 500, 100, "8 bpp, no cmap", DFLAG); + pixDisplayWithTitle(pix1, 100, 100, "8 bpp, cmap", 1); + pixDisplayWithTitle(pix2, 500, 100, "8 bpp, no cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 8 bpp <==> 8 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 8 bpp <==> 8 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); + pixDestroy(&pix1); + pixDestroy(&pix2); /* Conversion: 2 bpp cmap --> 32 bpp --> 2 bpp cmap */ - pixt1 = pixConvertTo8(pixc2, TRUE); - pixt2 = pixConvertTo32(pixt1); - pixt3 = pixConvertTo32(pixc2); - pixEqual(pixt2, pixt3, &same); + pix1 = pixConvertTo8(pixc2, TRUE); + pix2 = pixConvertTo32(pix1); + pix3 = pixConvertTo32(pixc2); + regTestComparePix(rp, pix2, pix3); /* 8 */ + pixEqual(pix2, pix3, &same); if (!same) { - pixDisplayWithTitle(pixt2, 100, 100, "32 bpp", DFLAG); - pixDisplayWithTitle(pixt3, 500, 100, "32 bpp", DFLAG); + pixDisplayWithTitle(pix2, 100, 100, "32 bpp", 1); + pixDisplayWithTitle(pix3, 500, 100, "32 bpp", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 2 bpp ==> 32 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 2 bpp <==> 32 bpp\n"); cmap = pixGetColormap(pixc2); - pixt4 = pixOctcubeQuantFromCmap(pixt3, cmap, 2, 4, L_EUCLIDEAN_DISTANCE); - pixEqual(pixc2, pixt4, &same); + pix4 = pixOctcubeQuantFromCmap(pix3, cmap, 2, 4, L_EUCLIDEAN_DISTANCE); + regTestComparePix(rp, pixc2, pix4); /* 9 */ + pixEqual(pixc2, pix4, &same); if (!same) { - pixDisplayWithTitle(pixc2, 100, 100, "4 bpp, cmap", DFLAG); - pixDisplayWithTitle(pixt4, 500, 100, "4 bpp, cmap", DFLAG); + pixDisplayWithTitle(pixc2, 100, 100, "4 bpp, cmap", 1); + pixDisplayWithTitle(pix4, 500, 100, "4 bpp, cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 2 bpp <==> 32 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 2 bpp <==> 32 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); - pixDestroy(&pixt3); - pixDestroy(&pixt4); + pixDestroy(&pix1); + pixDestroy(&pix2); + pixDestroy(&pix3); + pixDestroy(&pix4); /* Conversion: 4 bpp cmap --> 32 bpp --> 4 bpp cmap */ - pixt1 = pixConvertTo8(pixc4, TRUE); - pixt2 = pixConvertTo32(pixt1); - pixt3 = pixConvertTo32(pixc4); - pixEqual(pixt2, pixt3, &same); + pix1 = pixConvertTo8(pixc4, TRUE); + pix2 = pixConvertTo32(pix1); + pix3 = pixConvertTo32(pixc4); + regTestComparePix(rp, pix2, pix3); /* 10 */ + pixEqual(pix2, pix3, &same); if (!same) { - pixDisplayWithTitle(pixt2, 100, 100, "32 bpp", DFLAG); - pixDisplayWithTitle(pixt3, 500, 100, "32 bpp", DFLAG); + pixDisplayWithTitle(pix2, 100, 100, "32 bpp", 1); + pixDisplayWithTitle(pix3, 500, 100, "32 bpp", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 4 bpp ==> 32 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 4 bpp <==> 32 bpp\n"); cmap = pixGetColormap(pixc4); - pixt4 = pixOctcubeQuantFromCmap(pixt3, cmap, 2, 4, L_EUCLIDEAN_DISTANCE); - pixEqual(pixc4, pixt4, &same); + pix4 = pixOctcubeQuantFromCmap(pix3, cmap, 2, 4, L_EUCLIDEAN_DISTANCE); + regTestComparePix(rp, pixc4, pix4); /* 11 */ + pixEqual(pixc4, pix4, &same); if (!same) { - pixDisplayWithTitle(pixc4, 100, 100, "4 bpp, cmap", DFLAG); - pixDisplayWithTitle(pixt4, 500, 100, "4 bpp, cmap", DFLAG); + pixDisplayWithTitle(pixc4, 100, 100, "4 bpp, cmap", 1); + pixDisplayWithTitle(pix4, 500, 100, "4 bpp, cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 4 bpp <==> 32 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 4 bpp <==> 32 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); - pixDestroy(&pixt3); - pixDestroy(&pixt4); + pixDestroy(&pix1); + pixDestroy(&pix2); + pixDestroy(&pix3); + pixDestroy(&pix4); /* Conversion: 8 bpp --> 32 bpp --> 8 bpp */ - pixt1 = pixConvertTo32(pixs8); - pixt2 = pixConvertTo8(pixt1, FALSE); - pixEqual(pixs8, pixt2, &same); + pix1 = pixConvertTo32(pixs8); + pix2 = pixConvertTo8(pix1, FALSE); + regTestComparePix(rp, pixs8, pix2); /* 12 */ + pixEqual(pixs8, pix2, &same); if (!same) { - pixDisplayWithTitle(pixs8, 100, 100, "8 bpp", DFLAG); - pixDisplayWithTitle(pixt2, 500, 100, "8 bpp", DFLAG); + pixDisplayWithTitle(pixs8, 100, 100, "8 bpp", 1); + pixDisplayWithTitle(pix2, 500, 100, "8 bpp", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 8 bpp <==> 32 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 8 bpp <==> 32 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); + pixDestroy(&pix1); + pixDestroy(&pix2); /* Conversion: 8 bpp --> 16 bpp --> 8 bpp */ - pixt1 = pixConvert8To16(pixs8, 8); - pixt2 = pixConvertTo8(pixt1, FALSE); - pixEqual(pixs8, pixt2, &same); + pix1 = pixConvert8To16(pixs8, 8); + pix2 = pixConvertTo8(pix1, FALSE); + regTestComparePix(rp, pixs8, pix2); /* 13 */ + pixEqual(pixs8, pix2, &same); if (!same) { - pixDisplayWithTitle(pixs8, 100, 100, "8 bpp", DFLAG); - pixDisplayWithTitle(pixt2, 500, 100, "8 bpp", DFLAG); + pixDisplayWithTitle(pixs8, 100, 100, "8 bpp", 1); + pixDisplayWithTitle(pix2, 500, 100, "8 bpp", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 8 bpp <==> 16 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 8 bpp <==> 16 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); + pixDestroy(&pix1); + pixDestroy(&pix2); /* Conversion: 16 bpp --> 8 bpp --> 16 bpp */ - pixt1 = pixConvert16To8(pixs16, 1); - pixt2 = pixConvertTo16(pixt1); - pixWrite("/tmp/junkpix.png", pixt2, IFF_PNG); - pixEqual(pixs16, pixt2, &same); + pix1 = pixConvert16To8(pixs16, 1); + pix2 = pixConvertTo16(pix1); + pixWrite("/tmp/junkpix.png", pix2, IFF_PNG); + regTestComparePix(rp, pixs16, pix2); /* 14 */ + pixEqual(pixs16, pix2, &same); if (!same) { - pixDisplayWithTitle(pixs16, 100, 100, "16 bpp", DFLAG); - pixDisplayWithTitle(pixt2, 500, 100, "16 bpp", DFLAG); + pixDisplayWithTitle(pixs16, 100, 100, "16 bpp", 1); + pixDisplayWithTitle(pix2, 500, 100, "16 bpp", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 16 bpp <==> 8 bpp", L_COPY); } else fprintf(stderr, "OK: conversion 16 bpp <==> 8 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); + pixDestroy(&pix1); + pixDestroy(&pix2); /* Conversion: 8 bpp cmap --> 32 bpp --> 8 bpp cmap */ /* Required to go to level 6 of octcube to get identical result */ - pixt1 = pixConvertTo32(pixc8); + pix1 = pixConvertTo32(pixc8); cmap = pixGetColormap(pixc8); - pixt2 = pixOctcubeQuantFromCmap(pixt1, cmap, 2, 6, L_EUCLIDEAN_DISTANCE); - pixEqual(pixc8, pixt2, &same); + pix2 = pixOctcubeQuantFromCmap(pix1, cmap, 2, 6, L_EUCLIDEAN_DISTANCE); + regTestComparePix(rp, pixc8, pix2); /* 15 */ + pixEqual(pixc8, pix2, &same); if (!same) { - pixDisplayWithTitle(pixc8, 100, 100, "8 bpp cmap", DFLAG); - pixDisplayWithTitle(pixt2, 500, 100, "8 bpp cmap", DFLAG); + pixDisplayWithTitle(pixc8, 100, 100, "8 bpp cmap", 1); + pixDisplayWithTitle(pix2, 500, 100, "8 bpp cmap", 1); error = TRUE; sarrayAddString(sa, (char *)"conversion 8 bpp cmap <==> 32 bpp cmap", L_COPY); } else fprintf(stderr, "OK: conversion 8 bpp <==> 32 bpp\n"); - pixDestroy(&pixt1); - pixDestroy(&pixt2); + pixDestroy(&pix1); + pixDestroy(&pix2); /* Summarize results */ if (error == FALSE) @@ -324,6 +338,6 @@ static char mainName[] = "convert_reg"; pixDestroy(&pixc8); pixDestroy(&pixs16); pixDestroy(&pixs32); - return 0; + return regTestCleanup(rp); }