Leptonica 1.68
C Image Processing Library

binmorph1_reg.c

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 /*
00017  *  binmorph1_reg.c
00018  *
00019  *     This is a thorough regression test of different methods for
00020  *     doing binary morphology.  It should always be run if changes
00021  *     are made to the low-level morphology code.
00022  *
00023  *  Some things to note:
00024  *
00025  *  (1) We add a white border to guarantee safe closing; i.e., that
00026  *      closing is extensive for ASYMMETRIC_MORPH_BC.  The separable
00027  *      sequence for closing is not safe, so if we didn't add the border
00028  *      ab initio, we would get different results for the atomic sequence
00029  *      closing (which is safe) and the separable one.
00030  *
00031  *  (2) There are no differences in any of the operations:
00032  *           rasterop general
00033  *           rasterop brick
00034  *           morph sequence rasterop brick
00035  *           dwa brick
00036  *           morph sequence dwa brick
00037  *           morph sequence dwa composite brick
00038  *      when using ASYMMETRIC_MORPH_BC.
00039  *      However, when using SYMMETRIC_MORPH_BC, there are differences
00040  *      in two of the safe closing operations.  These differences
00041  *      are in pix numbers 4 and 5.  These differences are
00042  *      all due to the fact that for SYMMETRIC_MORPH_BC, we don't need
00043  *      to add any borders to get the correct answer.  When we do
00044  *      add a border of 0 pixels, we naturally get a different result.
00045  *
00046  *  (3) The 2-way Sel decomposition functions, implemented with the
00047  *      separable brick interface, are tested separately against
00048  *      the rasterop brick.  See binmorph2_reg.c.
00049  */
00050 
00051 #include "allheaders.h"
00052 
00053     /* set these ad lib. */
00054 #define    WIDTH            21    /* brick sel width */
00055 #define    HEIGHT           15    /* brick sel height */
00056 #define    TEST_SYMMETRIC   0     /* set to 1 to set symmetric b.c.;
00057                                      otherwise, it tests asymmetric b.c. */
00058 
00059 
00060 main(int    argc,
00061      char **argv)
00062 {
00063 l_int32      i, ok, same;
00064 char         sequence[512];
00065 PIX         *pixs, *pixref;
00066 PIX         *pixt1, *pixt2, *pixt3, *pixt4, *pixt5, *pixt6;
00067 PIX         *pixt7, *pixt8, *pixt9, *pixt10, *pixt11;
00068 PIX         *pixt12, *pixt13, *pixt14;
00069 SEL         *sel;
00070 static char  mainName[] = "binmorph1_reg";
00071 
00072     if (argc != 1)
00073         exit(ERROR_INT(" Syntax: binmorph1_reg", mainName, 1));
00074 
00075     if ((pixs = pixRead("feyn.tif")) == NULL)
00076         exit(ERROR_INT("pix not made", mainName, 1));
00077 
00078 #if TEST_SYMMETRIC
00079         /* This works properly if there is an added border */
00080     resetMorphBoundaryCondition(SYMMETRIC_MORPH_BC);
00081 #if 1
00082     pixt1 = pixAddBorder(pixs, 32, 0);
00083     pixTransferAllData(pixs, &pixt1, 0, 0);
00084 #endif
00085 #endif  /* TEST_SYMMETRIC */
00086 
00087         /* This is our test sel */
00088     sel = selCreateBrick(HEIGHT, WIDTH, HEIGHT / 2, WIDTH / 2, SEL_HIT);
00089 
00090         /* Dilation */
00091     fprintf(stderr, "Testing dilation\n");
00092     ok = TRUE;
00093     pixref = pixDilate(NULL, pixs, sel);   /* new one */
00094     pixt1 = pixCreateTemplate(pixs);
00095     pixDilate(pixt1, pixs, sel);           /* existing one */
00096     pixEqual(pixref, pixt1, &same);
00097     if (!same) {
00098         fprintf(stderr, "pixref != pixt1 !\n"); ok = FALSE;
00099     }
00100     pixt2 = pixCopy(NULL, pixs);
00101     pixDilate(pixt2, pixt2, sel);          /* in-place */
00102     pixEqual(pixref, pixt2, &same);
00103     if (!same) {
00104         fprintf(stderr, "pixref != pixt2 !\n"); ok = FALSE;
00105     }
00106     sprintf(sequence, "d%d.%d", WIDTH, HEIGHT);
00107     pixt3 = pixMorphSequence(pixs, sequence, 0);    /* sequence, atomic */
00108     pixEqual(pixref, pixt3, &same);
00109     if (!same) {
00110         fprintf(stderr, "pixref != pixt3 !\n"); ok = FALSE;
00111     }
00112     sprintf(sequence, "d%d.1 + d1.%d", WIDTH, HEIGHT);
00113     pixt4 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable */
00114     pixEqual(pixref, pixt4, &same);
00115     if (!same) {
00116         fprintf(stderr, "pixref != pixt4 !\n"); ok = FALSE;
00117     }
00118     pixt5 = pixDilateBrick(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00119     pixEqual(pixref, pixt5, &same);
00120     if (!same) {
00121         fprintf(stderr, "pixref != pixt5 !\n"); ok = FALSE;
00122     }
00123     pixt6 = pixCreateTemplate(pixs);
00124     pixDilateBrick(pixt6, pixs, WIDTH, HEIGHT);  /* existing one */
00125     pixEqual(pixref, pixt6, &same);
00126     if (!same) {
00127         fprintf(stderr, "pixref != pixt6 !\n"); ok = FALSE;
00128     }
00129     pixt7 = pixCopy(NULL, pixs);
00130     pixDilateBrick(pixt7, pixt7, WIDTH, HEIGHT);  /* in-place */
00131     pixEqual(pixref, pixt7, &same);
00132     if (!same) {
00133         fprintf(stderr, "pixref != pixt7 !\n"); ok = FALSE;
00134     }
00135     pixt8 = pixDilateBrickDwa(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00136     pixEqual(pixref, pixt8, &same);
00137     if (!same) {
00138         fprintf(stderr, "pixref != pixt8 !\n"); ok = FALSE;
00139     }
00140     pixt9 = pixCreateTemplate(pixs);
00141     pixDilateBrickDwa(pixt9, pixs, WIDTH, HEIGHT);  /* existing one */
00142     pixEqual(pixref, pixt9, &same);
00143     if (!same) {
00144         fprintf(stderr, "pixref != pixt9 !\n"); ok = FALSE;
00145     }
00146     pixt10 = pixCopy(NULL, pixs);
00147     pixDilateBrickDwa(pixt10, pixt10, WIDTH, HEIGHT);  /* in-place */
00148     pixEqual(pixref, pixt10, &same);
00149     if (!same) {
00150         fprintf(stderr, "pixref != pixt10 !\n"); ok = FALSE;
00151     }
00152     pixt11 = pixCreateTemplate(pixs);
00153     pixDilateCompBrickDwa(pixt11, pixs, WIDTH, HEIGHT);  /* existing one */
00154     pixEqual(pixref, pixt11, &same);
00155     if (!same) {
00156         fprintf(stderr, "pixref != pixt11 !\n"); ok = FALSE;
00157     }
00158     sprintf(sequence, "d%d.%d", WIDTH, HEIGHT);
00159     pixt12 = pixMorphCompSequence(pixs, sequence, 0);    /* comp sequence */
00160     pixEqual(pixref, pixt12, &same);
00161     if (!same) {
00162         fprintf(stderr, "pixref != pixt12!\n"); ok = FALSE;
00163     }
00164     pixt13 = pixMorphSequenceDwa(pixs, sequence, 0);    /* dwa sequence */
00165     pixEqual(pixref, pixt13, &same);
00166     if (!same) {
00167         fprintf(stderr, "pixref != pixt13!\n"); ok = FALSE;
00168     }
00169     pixDestroy(&pixref);
00170     pixDestroy(&pixt1);
00171     pixDestroy(&pixt2);
00172     pixDestroy(&pixt3);
00173     pixDestroy(&pixt4);
00174     pixDestroy(&pixt5);
00175     pixDestroy(&pixt6);
00176     pixDestroy(&pixt7);
00177     pixDestroy(&pixt8);
00178     pixDestroy(&pixt9);
00179     pixDestroy(&pixt10);
00180     pixDestroy(&pixt11);
00181     pixDestroy(&pixt12);
00182     pixDestroy(&pixt13);
00183 
00184         /* Erosion */
00185     fprintf(stderr, "Testing erosion\n");
00186     pixref = pixErode(NULL, pixs, sel);   /* new one */
00187     pixt1 = pixCreateTemplate(pixs);
00188     pixErode(pixt1, pixs, sel);           /* existing one */
00189     pixEqual(pixref, pixt1, &same);
00190     if (!same) {
00191         fprintf(stderr, "pixref != pixt1 !\n"); ok = FALSE;
00192     }
00193     pixt2 = pixCopy(NULL, pixs);
00194     pixErode(pixt2, pixt2, sel);          /* in-place */
00195     pixEqual(pixref, pixt2, &same);
00196     if (!same) {
00197         fprintf(stderr, "pixref != pixt2 !\n"); ok = FALSE;
00198     }
00199     sprintf(sequence, "e%d.%d", WIDTH, HEIGHT);
00200     pixt3 = pixMorphSequence(pixs, sequence, 0);    /* sequence, atomic */
00201     pixEqual(pixref, pixt3, &same);
00202     if (!same) {
00203         fprintf(stderr, "pixref != pixt3 !\n"); ok = FALSE;
00204     }
00205     sprintf(sequence, "e%d.1 + e1.%d", WIDTH, HEIGHT);
00206     pixt4 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable */
00207     pixEqual(pixref, pixt4, &same);
00208     if (!same) {
00209         fprintf(stderr, "pixref != pixt4 !\n"); ok = FALSE;
00210     }
00211     pixt5 = pixErodeBrick(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00212     pixEqual(pixref, pixt5, &same);
00213     if (!same) {
00214         fprintf(stderr, "pixref != pixt5 !\n"); ok = FALSE;
00215     }
00216     pixt6 = pixCreateTemplate(pixs);
00217     pixErodeBrick(pixt6, pixs, WIDTH, HEIGHT);  /* existing one */
00218     pixEqual(pixref, pixt6, &same);
00219     if (!same) {
00220         fprintf(stderr, "pixref != pixt6 !\n"); ok = FALSE;
00221     }
00222     pixt7 = pixCopy(NULL, pixs);
00223     pixErodeBrick(pixt7, pixt7, WIDTH, HEIGHT);  /* in-place */
00224     pixEqual(pixref, pixt7, &same);
00225     if (!same) {
00226         fprintf(stderr, "pixref != pixt7 !\n"); ok = FALSE;
00227     }
00228     pixt8 = pixErodeBrickDwa(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00229     pixEqual(pixref, pixt8, &same);
00230     if (!same) {
00231         fprintf(stderr, "pixref != pixt8 !\n"); ok = FALSE;
00232     }
00233     pixt9 = pixCreateTemplate(pixs);
00234     pixErodeBrickDwa(pixt9, pixs, WIDTH, HEIGHT);  /* existing one */
00235     pixEqual(pixref, pixt9, &same);
00236     if (!same) {
00237         fprintf(stderr, "pixref != pixt9 !\n"); ok = FALSE;
00238     }
00239     pixt10 = pixCopy(NULL, pixs);
00240     pixErodeBrickDwa(pixt10, pixt10, WIDTH, HEIGHT);  /* in-place */
00241     pixEqual(pixref, pixt10, &same);
00242     if (!same) {
00243         fprintf(stderr, "pixref != pixt10 !\n"); ok = FALSE;
00244     }
00245     pixt11 = pixCreateTemplate(pixs);
00246     pixErodeCompBrickDwa(pixt11, pixs, WIDTH, HEIGHT);  /* existing one */
00247     pixEqual(pixref, pixt11, &same);
00248     if (!same) {
00249         fprintf(stderr, "pixref != pixt11 !\n"); ok = FALSE;
00250     }
00251     
00252     sprintf(sequence, "e%d.%d", WIDTH, HEIGHT);
00253     pixt12 = pixMorphCompSequence(pixs, sequence, 0);    /* comp sequence */
00254     pixEqual(pixref, pixt12, &same);
00255     if (!same) {
00256         fprintf(stderr, "pixref != pixt12!\n"); ok = FALSE;
00257     }
00258     pixt13 = pixMorphSequenceDwa(pixs, sequence, 0);    /* dwa sequence */
00259     pixEqual(pixref, pixt13, &same);
00260     if (!same) {
00261         fprintf(stderr, "pixref != pixt13!\n"); ok = FALSE;
00262     }
00263     pixDestroy(&pixref);
00264     pixDestroy(&pixt1);
00265     pixDestroy(&pixt2);
00266     pixDestroy(&pixt3);
00267     pixDestroy(&pixt4);
00268     pixDestroy(&pixt5);
00269     pixDestroy(&pixt6);
00270     pixDestroy(&pixt7);
00271     pixDestroy(&pixt8);
00272     pixDestroy(&pixt9);
00273     pixDestroy(&pixt10);
00274     pixDestroy(&pixt11);
00275     pixDestroy(&pixt12);
00276     pixDestroy(&pixt13);
00277 
00278         /* Opening */
00279     fprintf(stderr, "Testing opening\n");
00280     pixref = pixOpen(NULL, pixs, sel);   /* new one */
00281     pixt1 = pixCreateTemplate(pixs);
00282     pixOpen(pixt1, pixs, sel);           /* existing one */
00283     pixEqual(pixref, pixt1, &same);
00284     if (!same) {
00285         fprintf(stderr, "pixref != pixt1 !\n"); ok = FALSE;
00286     }
00287     pixt2 = pixCopy(NULL, pixs);
00288     pixOpen(pixt2, pixt2, sel);          /* in-place */
00289     pixEqual(pixref, pixt2, &same);
00290     if (!same) {
00291         fprintf(stderr, "pixref != pixt2 !\n"); ok = FALSE;
00292     }
00293     sprintf(sequence, "o%d.%d", WIDTH, HEIGHT);
00294     pixt3 = pixMorphSequence(pixs, sequence, 0);    /* sequence, atomic */
00295     pixEqual(pixref, pixt3, &same);
00296     if (!same) {
00297         fprintf(stderr, "pixref != pixt3 !\n"); ok = FALSE;
00298     }
00299     sprintf(sequence, "e%d.%d + d%d.%d", WIDTH, HEIGHT, WIDTH, HEIGHT);
00300     pixt4 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable */
00301     pixEqual(pixref, pixt4, &same);
00302     if (!same) {
00303         fprintf(stderr, "pixref != pixt4 !\n"); ok = FALSE;
00304     }
00305     sprintf(sequence, "e%d.1 + e1.%d + d%d.1 + d1.%d", WIDTH, HEIGHT,
00306             WIDTH, HEIGHT);
00307     pixt5 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable^2 */
00308     pixEqual(pixref, pixt5, &same);
00309     if (!same) {
00310         fprintf(stderr, "pixref != pixt5 !\n"); ok = FALSE;
00311     }
00312     pixt6 = pixOpenBrick(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00313     pixEqual(pixref, pixt6, &same);
00314     if (!same) {
00315         fprintf(stderr, "pixref != pixt6 !\n"); ok = FALSE;
00316     }
00317     pixt7 = pixCreateTemplate(pixs);
00318     pixOpenBrick(pixt7, pixs, WIDTH, HEIGHT);  /* existing one */
00319     pixEqual(pixref, pixt7, &same);
00320     if (!same) {
00321         fprintf(stderr, "pixref != pixt7 !\n"); ok = FALSE;
00322     }
00323     pixt8 = pixCopy(NULL, pixs);  /* in-place */
00324     pixOpenBrick(pixt8, pixt8, WIDTH, HEIGHT);  /* existing one */
00325     pixEqual(pixref, pixt8, &same);
00326     if (!same) {
00327         fprintf(stderr, "pixref != pixt8 !\n"); ok = FALSE;
00328     }
00329     pixt9 = pixOpenBrickDwa(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00330     pixEqual(pixref, pixt9, &same);
00331     if (!same) {
00332         fprintf(stderr, "pixref != pixt9 !\n"); ok = FALSE;
00333     }
00334     pixt10 = pixCreateTemplate(pixs);
00335     pixOpenBrickDwa(pixt10, pixs, WIDTH, HEIGHT);  /* existing one */
00336     pixEqual(pixref, pixt10, &same);
00337     if (!same) {
00338         fprintf(stderr, "pixref != pixt10 !\n"); ok = FALSE;
00339     }
00340     pixt11 = pixCopy(NULL, pixs);
00341     pixOpenBrickDwa(pixt11, pixt11, WIDTH, HEIGHT);  /* in-place */
00342     pixEqual(pixref, pixt11, &same);
00343     if (!same) {
00344         fprintf(stderr, "pixref != pixt11 !\n"); ok = FALSE;
00345     }
00346     sprintf(sequence, "o%d.%d", WIDTH, HEIGHT);
00347     pixt12 = pixMorphCompSequence(pixs, sequence, 0);    /* comp sequence */
00348     pixEqual(pixref, pixt12, &same);
00349     if (!same) {
00350         fprintf(stderr, "pixref != pixt12!\n"); ok = FALSE;
00351     }
00352 
00353 #if 0
00354     pixWrite("/tmp/junkref.png", pixref, IFF_PNG);
00355     pixWrite("/tmp/junk12.png", pixt12, IFF_PNG);
00356     pixt13 = pixXor(NULL, pixref, pixt12);
00357     pixWrite("/tmp/junk12a.png", pixt13, IFF_PNG);
00358     pixDestroy(&pixt13);
00359 #endif
00360 
00361     pixt13 = pixMorphSequenceDwa(pixs, sequence, 0);    /* dwa sequence */
00362     pixEqual(pixref, pixt13, &same);
00363     if (!same) {
00364         fprintf(stderr, "pixref != pixt13!\n"); ok = FALSE;
00365     }
00366     pixt14 = pixCreateTemplate(pixs);
00367     pixOpenCompBrickDwa(pixt14, pixs, WIDTH, HEIGHT);  /* existing one */
00368     pixEqual(pixref, pixt14, &same);
00369     if (!same) {
00370         fprintf(stderr, "pixref != pixt14 !\n"); ok = FALSE;
00371     }
00372 
00373     pixDestroy(&pixref);
00374     pixDestroy(&pixt1);
00375     pixDestroy(&pixt2);
00376     pixDestroy(&pixt3);
00377     pixDestroy(&pixt4);
00378     pixDestroy(&pixt5);
00379     pixDestroy(&pixt6);
00380     pixDestroy(&pixt7);
00381     pixDestroy(&pixt8);
00382     pixDestroy(&pixt9);
00383     pixDestroy(&pixt10);
00384     pixDestroy(&pixt11);
00385     pixDestroy(&pixt12);
00386     pixDestroy(&pixt13);
00387     pixDestroy(&pixt14);
00388 
00389         /* Closing */
00390     fprintf(stderr, "Testing closing\n");
00391     pixref = pixClose(NULL, pixs, sel);   /* new one */
00392     pixt1 = pixCreateTemplate(pixs);
00393     pixClose(pixt1, pixs, sel);           /* existing one */
00394     pixEqual(pixref, pixt1, &same);
00395     if (!same) {
00396         fprintf(stderr, "pixref != pixt1 !\n"); ok = FALSE;
00397     }
00398     pixt2 = pixCopy(NULL, pixs);
00399     pixClose(pixt2, pixt2, sel);          /* in-place */
00400     pixEqual(pixref, pixt2, &same);
00401     if (!same) {
00402         fprintf(stderr, "pixref != pixt2 !\n"); ok = FALSE;
00403     }
00404     sprintf(sequence, "d%d.%d + e%d.%d", WIDTH, HEIGHT, WIDTH, HEIGHT);
00405     pixt3 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable */
00406     pixEqual(pixref, pixt3, &same);
00407     if (!same) {
00408         fprintf(stderr, "pixref != pixt3 !\n"); ok = FALSE;
00409     }
00410     sprintf(sequence, "d%d.1 + d1.%d + e%d.1 + e1.%d", WIDTH, HEIGHT,
00411             WIDTH, HEIGHT);
00412     pixt4 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable^2 */
00413     pixEqual(pixref, pixt4, &same);
00414     if (!same) {
00415         fprintf(stderr, "pixref != pixt4 !\n"); ok = FALSE;
00416     }
00417     pixt5 = pixCloseBrick(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00418     pixEqual(pixref, pixt5, &same);
00419     if (!same) {
00420         fprintf(stderr, "pixref != pixt5 !\n"); ok = FALSE;
00421     }
00422     pixt6 = pixCreateTemplate(pixs);
00423     pixCloseBrick(pixt6, pixs, WIDTH, HEIGHT);  /* existing one */
00424     pixEqual(pixref, pixt6, &same);
00425     if (!same) {
00426         fprintf(stderr, "pixref != pixt6 !\n"); ok = FALSE;
00427     }
00428     pixt7 = pixCopy(NULL, pixs);  /* in-place */
00429     pixCloseBrick(pixt7, pixt7, WIDTH, HEIGHT);  /* existing one */
00430     pixEqual(pixref, pixt7, &same);
00431     if (!same) {
00432         fprintf(stderr, "pixref != pixt7 !\n"); ok = FALSE;
00433     }
00434     pixDestroy(&pixref);
00435     pixDestroy(&pixt1);
00436     pixDestroy(&pixt2);
00437     pixDestroy(&pixt3);
00438     pixDestroy(&pixt4);
00439     pixDestroy(&pixt5);
00440     pixDestroy(&pixt6);
00441     pixDestroy(&pixt7);
00442 
00443         /* Safe closing (using pix, not pixs) */
00444     fprintf(stderr, "Testing safe closing\n");
00445     pixref = pixCloseSafe(NULL, pixs, sel);   /* new one */
00446     pixt1 = pixCreateTemplate(pixs);
00447     pixCloseSafe(pixt1, pixs, sel);           /* existing one */
00448     pixEqual(pixref, pixt1, &same);
00449     if (!same) {
00450         fprintf(stderr, "pixref != pixt1 !\n"); ok = FALSE;
00451     }
00452     pixt2 = pixCopy(NULL, pixs);
00453     pixCloseSafe(pixt2, pixt2, sel);          /* in-place */
00454     pixEqual(pixref, pixt2, &same);
00455     if (!same) {
00456         fprintf(stderr, "pixref != pixt2 !\n"); ok = FALSE;
00457     }
00458     sprintf(sequence, "c%d.%d", WIDTH, HEIGHT);
00459     pixt3 = pixMorphSequence(pixs, sequence, 0);    /* sequence, atomic */
00460     pixEqual(pixref, pixt3, &same);
00461     if (!same) {
00462         fprintf(stderr, "pixref != pixt3 !\n"); ok = FALSE;
00463     }
00464     sprintf(sequence, "b32 + d%d.%d + e%d.%d", WIDTH, HEIGHT, WIDTH, HEIGHT);
00465     pixt4 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable */
00466     pixEqual(pixref, pixt4, &same);
00467     if (!same) {
00468         fprintf(stderr, "pixref != pixt4 !\n"); ok = FALSE;
00469     }
00470     sprintf(sequence, "b32 + d%d.1 + d1.%d + e%d.1 + e1.%d", WIDTH, HEIGHT,
00471             WIDTH, HEIGHT);
00472     pixt5 = pixMorphSequence(pixs, sequence, 0);    /* sequence, separable^2 */
00473     pixEqual(pixref, pixt5, &same);
00474     if (!same) {
00475         fprintf(stderr, "pixref != pixt5 !\n"); ok = FALSE;
00476     }
00477     pixt6 = pixCloseSafeBrick(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00478     pixEqual(pixref, pixt6, &same);
00479     if (!same) {
00480         fprintf(stderr, "pixref != pixt6 !\n"); ok = FALSE;
00481     }
00482     pixt7 = pixCreateTemplate(pixs);
00483     pixCloseSafeBrick(pixt7, pixs, WIDTH, HEIGHT);  /* existing one */
00484     pixEqual(pixref, pixt7, &same);
00485     if (!same) {
00486         fprintf(stderr, "pixref != pixt7 !\n"); ok = FALSE;
00487     }
00488     pixt8 = pixCopy(NULL, pixs);  /* in-place */
00489     pixCloseSafeBrick(pixt8, pixt8, WIDTH, HEIGHT);  /* existing one */
00490     pixEqual(pixref, pixt8, &same);
00491     if (!same) {
00492         fprintf(stderr, "pixref != pixt8 !\n"); ok = FALSE;
00493     }
00494     pixt9 = pixCloseBrickDwa(NULL, pixs, WIDTH, HEIGHT);  /* new one */
00495     pixEqual(pixref, pixt9, &same);
00496     if (!same) {
00497         fprintf(stderr, "pixref != pixt9 !\n"); ok = FALSE;
00498     }
00499     pixt10 = pixCreateTemplate(pixs);
00500     pixCloseBrickDwa(pixt10, pixs, WIDTH, HEIGHT);  /* existing one */
00501     pixEqual(pixref, pixt10, &same);
00502     if (!same) {
00503         fprintf(stderr, "pixref != pixt10 !\n"); ok = FALSE;
00504     }
00505     pixt11 = pixCopy(NULL, pixs);
00506     pixCloseBrickDwa(pixt11, pixt11, WIDTH, HEIGHT);  /* in-place */
00507     pixEqual(pixref, pixt11, &same);
00508     if (!same) {
00509         fprintf(stderr, "pixref != pixt11 !\n"); ok = FALSE;
00510     }
00511     sprintf(sequence, "c%d.%d", WIDTH, HEIGHT);
00512     pixt12 = pixMorphCompSequence(pixs, sequence, 0);    /* comp sequence */
00513     pixEqual(pixref, pixt12, &same);
00514     if (!same) {
00515         fprintf(stderr, "pixref != pixt12!\n"); ok = FALSE;
00516     }
00517     pixt13 = pixMorphSequenceDwa(pixs, sequence, 0);    /* dwa sequence */
00518     pixEqual(pixref, pixt13, &same);
00519     if (!same) {
00520         fprintf(stderr, "pixref != pixt13!\n"); ok = FALSE;
00521     }
00522     pixt14 = pixCreateTemplate(pixs);
00523     pixCloseCompBrickDwa(pixt14, pixs, WIDTH, HEIGHT);  /* existing one */
00524     pixEqual(pixref, pixt14, &same);
00525     if (!same) {
00526         fprintf(stderr, "pixref != pixt14 !\n"); ok = FALSE;
00527     }
00528 
00529 #if 0
00530     pixWrite("/tmp/junkref.png", pixref, IFF_PNG);
00531     pixWrite("/tmp/junk12.png", pixt12, IFF_PNG);
00532     pixt13 = pixXor(NULL, pixref, pixt12);
00533     pixWrite("/tmp/junk12a.png", pixt13, IFF_PNG);
00534     pixDestroy(&pixt13);
00535 #endif
00536 
00537     pixDestroy(&pixref);
00538     pixDestroy(&pixt1);
00539     pixDestroy(&pixt2);
00540     pixDestroy(&pixt3);
00541     pixDestroy(&pixt4);
00542     pixDestroy(&pixt5);
00543     pixDestroy(&pixt6);
00544     pixDestroy(&pixt7);
00545     pixDestroy(&pixt8);
00546     pixDestroy(&pixt9);
00547     pixDestroy(&pixt10);
00548     pixDestroy(&pixt11);
00549     pixDestroy(&pixt12);
00550     pixDestroy(&pixt13);
00551     pixDestroy(&pixt14);
00552 
00553     if (ok)
00554         fprintf(stderr, "All morph tests OK!\n");
00555 
00556     pixDestroy(&pixs);
00557     selDestroy(&sel);
00558     exit(0);
00559 }
00560 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines