Leptonica 1.68
C Image Processing Library
|
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 * binmorph4_reg.c 00018 * 00019 * Regression test for dwa brick morph operations 00020 * We compare: 00021 * (1) morph composite vs. morph non-composite 00022 * (2) dwa non-composite vs. morph composite 00023 * (3) dwa composite vs. dwa non-composite 00024 * (4) dwa composite vs. morph composite 00025 * (5) dwa composite vs. morph non-composite 00026 * The brick functions all have a pre-allocated pix as the dest. 00027 */ 00028 00029 #include <stdio.h> 00030 #include <stdlib.h> 00031 #include "allheaders.h" 00032 00033 l_int32 DoComparisonDwa1(PIX *pixs, PIX *pixt1, PIX *pixt2, PIX *pixt3, 00034 PIX *pixt4, PIX *pixt5, PIX *pixt6, l_int32 isize); 00035 l_int32 DoComparisonDwa2(PIX *pixs, PIX *pixt1, PIX *pixt2, PIX *pixt3, 00036 PIX *pixt4, PIX *pixt5, PIX *pixt6, l_int32 isize); 00037 l_int32 DoComparisonDwa3(PIX *pixs, PIX *pixt1, PIX *pixt2, PIX *pixt3, 00038 PIX *pixt4, PIX *pixt5, PIX *pixt6, l_int32 isize); 00039 l_int32 DoComparisonDwa4(PIX *pixs, PIX *pixt1, PIX *pixt2, PIX *pixt3, 00040 PIX *pixt4, PIX *pixt5, PIX *pixt6, l_int32 isize); 00041 l_int32 DoComparisonDwa5(PIX *pixs, PIX *pixt1, PIX *pixt2, PIX *pixt3, 00042 PIX *pixt4, PIX *pixt5, PIX *pixt6, l_int32 isize); 00043 l_int32 PixCompareDwa(l_int32 size, const char *type, PIX *pixt1, PIX *pixt2, 00044 PIX *pixt3, PIX *pixt4, PIX *pixt5, PIX *pixt6); 00045 00046 #define TIMING 0 00047 00048 /* This fails on the symmetric case, but the differences are 00049 * relatively small. Most of the problems seems to be in the 00050 * non-dwa code, because we are doing sequential erosions 00051 * without an extra border, and things aren't being properly 00052 * initialized. To avoid these errors, add a border in advance 00053 * for symmetric b.c. Note that asymmetric b.c. are recommended 00054 * for document image operations, and this test passes for 00055 * asymmetric b.c. */ 00056 #define TEST_SYMMETRIC 0 /* set to 1 for symmetric b.c.; 00057 otherwise, it tests asymmetric b.c. */ 00058 00059 00060 main(int argc, 00061 char **argv) 00062 { 00063 l_int32 i; 00064 PIX *pixs, *pixt0, *pixt1, *pixt2, *pixt3, *pixt4, *pixt5, *pixt6; 00065 static char mainName[] = "binmorph4_reg"; 00066 00067 pixs = pixRead("feyn.tif"); 00068 00069 #if TEST_SYMMETRIC 00070 /* This works properly if there is an added border */ 00071 resetMorphBoundaryCondition(SYMMETRIC_MORPH_BC); 00072 #if 1 00073 pixt1 = pixAddBorder(pixs, 64, 0); 00074 pixTransferAllData(pixs, &pixt1, 0, 0); 00075 #endif 00076 #endif /* TEST_SYMMETRIC */ 00077 00078 pixt1 = pixCreateTemplateNoInit(pixs); 00079 pixt2 = pixCreateTemplateNoInit(pixs); 00080 pixt3 = pixCreateTemplateNoInit(pixs); 00081 pixt4 = pixCreateTemplateNoInit(pixs); 00082 pixt5 = pixCreateTemplateNoInit(pixs); 00083 pixt6 = pixCreateTemplateNoInit(pixs); 00084 00085 for (i = 2; i < 64; i++) { 00086 00087 #if 1 00088 /* Compare morph composite with morph non-composite */ 00089 DoComparisonDwa1(pixs, pixt1, pixt2, pixt3, pixt4, 00090 pixt5, pixt6, i); 00091 #endif 00092 00093 #if 1 00094 /* Compare DWA non-composite with morph composite */ 00095 if (i < 16) 00096 DoComparisonDwa2(pixs, pixt1, pixt2, pixt3, pixt4, 00097 pixt5, pixt6, i); 00098 /* Compare DWA composite with DWA non-composite */ 00099 if (i < 16) 00100 DoComparisonDwa3(pixs, pixt1, pixt2, pixt3, pixt4, 00101 pixt5, pixt6, i); 00102 /* Compare DWA composite with morph composite */ 00103 DoComparisonDwa4(pixs, pixt1, pixt2, pixt3, pixt4, 00104 pixt5, pixt6, i); 00105 /* Compare DWA composite with morph non-composite */ 00106 DoComparisonDwa5(pixs, pixt1, pixt2, pixt3, pixt4, 00107 pixt5, pixt6, i); 00108 #endif 00109 } 00110 00111 pixDestroy(&pixs); 00112 pixDestroy(&pixt1); 00113 pixDestroy(&pixt2); 00114 pixDestroy(&pixt3); 00115 pixDestroy(&pixt4); 00116 pixDestroy(&pixt5); 00117 pixDestroy(&pixt6); 00118 return 0; 00119 } 00120 00121 /* morph composite with morph non-composite */ 00122 l_int32 00123 DoComparisonDwa1(PIX *pixs, 00124 PIX *pixt1, 00125 PIX *pixt2, 00126 PIX *pixt3, 00127 PIX *pixt4, 00128 PIX *pixt5, 00129 PIX *pixt6, 00130 l_int32 isize) 00131 { 00132 l_int32 fact1, fact2, size; 00133 00134 selectComposableSizes(isize, &fact1, &fact2); 00135 size = fact1 * fact2; 00136 00137 fprintf(stderr, "..%d..", size); 00138 00139 if (TIMING) startTimer(); 00140 pixDilateCompBrick(pixt1, pixs, size, 1); 00141 pixDilateCompBrick(pixt3, pixs, 1, size); 00142 pixDilateCompBrick(pixt5, pixs, size, size); 00143 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00144 if (TIMING) startTimer(); 00145 pixDilateBrick(pixt2, pixs, size, 1); 00146 pixDilateBrick(pixt4, pixs, 1, size); 00147 pixDilateBrick(pixt6, pixs, size, size); 00148 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00149 PixCompareDwa(size, "dilate", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00150 00151 if (TIMING) startTimer(); 00152 pixErodeCompBrick(pixt1, pixs, size, 1); 00153 pixErodeCompBrick(pixt3, pixs, 1, size); 00154 pixErodeCompBrick(pixt5, pixs, size, size); 00155 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00156 if (TIMING) startTimer(); 00157 pixErodeBrick(pixt2, pixs, size, 1); 00158 pixErodeBrick(pixt4, pixs, 1, size); 00159 pixErodeBrick(pixt6, pixs, size, size); 00160 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00161 PixCompareDwa(size, "erode", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00162 00163 if (TIMING) startTimer(); 00164 pixOpenCompBrick(pixt1, pixs, size, 1); 00165 pixOpenCompBrick(pixt3, pixs, 1, size); 00166 pixOpenCompBrick(pixt5, pixs, size, size); 00167 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00168 if (TIMING) startTimer(); 00169 pixOpenBrick(pixt2, pixs, size, 1); 00170 pixOpenBrick(pixt4, pixs, 1, size); 00171 pixOpenBrick(pixt6, pixs, size, size); 00172 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00173 PixCompareDwa(size, "open", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00174 00175 #if 1 00176 pixWrite("/tmp/junko1.png", pixt1, IFF_PNG); 00177 pixWrite("/tmp/junko2.png", pixt2, IFF_PNG); 00178 pixXor(pixt1, pixt1, pixt2); 00179 pixWrite("/tmp/junkoxor.png", pixt1, IFF_PNG); 00180 #endif 00181 00182 #if 0 00183 pixDisplay(pixt1, 100, 100); 00184 pixDisplay(pixt2, 800, 100); 00185 pixWrite("/tmp/junkpixt1.png", pixt1, IFF_PNG); 00186 pixWrite("/tmp/junkpixt2.png", pixt2, IFF_PNG); 00187 #endif 00188 00189 if (TIMING) startTimer(); 00190 pixCloseSafeCompBrick(pixt1, pixs, size, 1); 00191 pixCloseSafeCompBrick(pixt3, pixs, 1, size); 00192 pixCloseSafeCompBrick(pixt5, pixs, size, size); 00193 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00194 if (TIMING) startTimer(); 00195 pixCloseSafeBrick(pixt2, pixs, size, 1); 00196 pixCloseSafeBrick(pixt4, pixs, 1, size); 00197 pixCloseSafeBrick(pixt6, pixs, size, size); 00198 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00199 PixCompareDwa(size, "close", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00200 00201 #if 1 00202 pixWrite("/tmp/junkc1.png", pixt1, IFF_PNG); 00203 pixWrite("/tmp/junkc2.png", pixt2, IFF_PNG); 00204 pixXor(pixt1, pixt1, pixt2); 00205 pixWrite("/tmp/junkcxor.png", pixt1, IFF_PNG); 00206 #endif 00207 00208 return 0; 00209 } 00210 00211 00212 /* dwa non-composite with morph composite */ 00213 l_int32 00214 DoComparisonDwa2(PIX *pixs, 00215 PIX *pixt1, 00216 PIX *pixt2, 00217 PIX *pixt3, 00218 PIX *pixt4, 00219 PIX *pixt5, 00220 PIX *pixt6, 00221 l_int32 isize) 00222 { 00223 l_int32 fact1, fact2, size; 00224 00225 selectComposableSizes(isize, &fact1, &fact2); 00226 size = fact1 * fact2; 00227 00228 fprintf(stderr, "..%d..", size); 00229 00230 if (TIMING) startTimer(); 00231 pixDilateBrickDwa(pixt1, pixs, size, 1); 00232 pixDilateBrickDwa(pixt3, pixs, 1, size); 00233 pixDilateBrickDwa(pixt5, pixs, size, size); 00234 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00235 if (TIMING) startTimer(); 00236 pixDilateCompBrick(pixt2, pixs, size, 1); 00237 pixDilateCompBrick(pixt4, pixs, 1, size); 00238 pixDilateCompBrick(pixt6, pixs, size, size); 00239 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00240 PixCompareDwa(size, "dilate", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00241 00242 /* pixDisplay(pixt1, 100, 100); */ 00243 /* pixDisplay(pixt2, 800, 100); */ 00244 00245 if (TIMING) startTimer(); 00246 pixErodeBrickDwa(pixt1, pixs, size, 1); 00247 pixErodeBrickDwa(pixt3, pixs, 1, size); 00248 pixErodeBrickDwa(pixt5, pixs, size, size); 00249 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00250 if (TIMING) startTimer(); 00251 pixErodeCompBrick(pixt2, pixs, size, 1); 00252 pixErodeCompBrick(pixt4, pixs, 1, size); 00253 pixErodeCompBrick(pixt6, pixs, size, size); 00254 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00255 PixCompareDwa(size, "erode", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00256 00257 if (TIMING) startTimer(); 00258 pixOpenBrickDwa(pixt1, pixs, size, 1); 00259 pixOpenBrickDwa(pixt3, pixs, 1, size); 00260 pixOpenBrickDwa(pixt5, pixs, size, size); 00261 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00262 if (TIMING) startTimer(); 00263 pixOpenCompBrick(pixt2, pixs, size, 1); 00264 pixOpenCompBrick(pixt4, pixs, 1, size); 00265 pixOpenCompBrick(pixt6, pixs, size, size); 00266 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00267 PixCompareDwa(size, "open", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00268 00269 if (TIMING) startTimer(); 00270 pixCloseBrickDwa(pixt1, pixs, size, 1); 00271 pixCloseBrickDwa(pixt3, pixs, 1, size); 00272 pixCloseBrickDwa(pixt5, pixs, size, size); 00273 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00274 if (TIMING) startTimer(); 00275 pixCloseSafeCompBrick(pixt2, pixs, size, 1); 00276 pixCloseSafeCompBrick(pixt4, pixs, 1, size); 00277 pixCloseSafeCompBrick(pixt6, pixs, size, size); 00278 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00279 PixCompareDwa(size, "close", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00280 00281 /* pixWrite("/tmp/junkpixt1.png", pixt1, IFF_PNG); */ 00282 /* pixWrite("/tmp/junkpixt2.png", pixt2, IFF_PNG); */ 00283 /* pixXor(pixt1, pixt1, pixt2); */ 00284 /* pixWrite("/tmp/junkxor.png", pixt1, IFF_PNG); */ 00285 00286 return 0; 00287 } 00288 00289 00290 /* dwa composite with dwa non-composite */ 00291 l_int32 00292 DoComparisonDwa3(PIX *pixs, 00293 PIX *pixt1, 00294 PIX *pixt2, 00295 PIX *pixt3, 00296 PIX *pixt4, 00297 PIX *pixt5, 00298 PIX *pixt6, 00299 l_int32 isize) 00300 { 00301 l_int32 fact1, fact2, size; 00302 00303 selectComposableSizes(isize, &fact1, &fact2); 00304 size = fact1 * fact2; 00305 00306 fprintf(stderr, "..%d..", size); 00307 00308 if (TIMING) startTimer(); 00309 pixDilateCompBrickDwa(pixt1, pixs, size, 1); 00310 pixDilateCompBrickDwa(pixt3, pixs, 1, size); 00311 pixDilateCompBrickDwa(pixt5, pixs, size, size); 00312 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00313 if (TIMING) startTimer(); 00314 pixDilateBrickDwa(pixt2, pixs, size, 1); 00315 pixDilateBrickDwa(pixt4, pixs, 1, size); 00316 pixDilateBrickDwa(pixt6, pixs, size, size); 00317 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00318 PixCompareDwa(size, "dilate", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00319 00320 /* pixDisplay(pixt1, 100, 100); */ 00321 /* pixDisplay(pixt2, 800, 100); */ 00322 00323 if (TIMING) startTimer(); 00324 pixErodeCompBrickDwa(pixt1, pixs, size, 1); 00325 pixErodeCompBrickDwa(pixt3, pixs, 1, size); 00326 pixErodeCompBrickDwa(pixt5, pixs, size, size); 00327 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00328 if (TIMING) startTimer(); 00329 pixErodeBrickDwa(pixt2, pixs, size, 1); 00330 pixErodeBrickDwa(pixt4, pixs, 1, size); 00331 pixErodeBrickDwa(pixt6, pixs, size, size); 00332 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00333 PixCompareDwa(size, "erode", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00334 00335 if (TIMING) startTimer(); 00336 pixOpenCompBrickDwa(pixt1, pixs, size, 1); 00337 pixOpenCompBrickDwa(pixt3, pixs, 1, size); 00338 pixOpenCompBrickDwa(pixt5, pixs, size, size); 00339 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00340 if (TIMING) startTimer(); 00341 pixOpenBrickDwa(pixt2, pixs, size, 1); 00342 pixOpenBrickDwa(pixt4, pixs, 1, size); 00343 pixOpenBrickDwa(pixt6, pixs, size, size); 00344 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00345 PixCompareDwa(size, "open", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00346 00347 if (TIMING) startTimer(); 00348 pixCloseCompBrickDwa(pixt1, pixs, size, 1); 00349 pixCloseCompBrickDwa(pixt3, pixs, 1, size); 00350 pixCloseCompBrickDwa(pixt5, pixs, size, size); 00351 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00352 if (TIMING) startTimer(); 00353 pixCloseBrickDwa(pixt2, pixs, size, 1); 00354 pixCloseBrickDwa(pixt4, pixs, 1, size); 00355 pixCloseBrickDwa(pixt6, pixs, size, size); 00356 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00357 PixCompareDwa(size, "close", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00358 00359 #if 0 00360 pixWrite("/tmp/junkpixt1.png", pixt1, IFF_PNG); 00361 pixWrite("/tmp/junkpixt2.png", pixt2, IFF_PNG); 00362 pixXor(pixt1, pixt1, pixt2); 00363 pixWrite("/tmp/junkxor.png", pixt1, IFF_PNG); 00364 #endif 00365 00366 return 0; 00367 } 00368 00369 00370 /* dwa composite with morph composite */ 00371 l_int32 00372 DoComparisonDwa4(PIX *pixs, 00373 PIX *pixt1, 00374 PIX *pixt2, 00375 PIX *pixt3, 00376 PIX *pixt4, 00377 PIX *pixt5, 00378 PIX *pixt6, 00379 l_int32 isize) 00380 { 00381 l_int32 fact1, fact2, size; 00382 00383 selectComposableSizes(isize, &fact1, &fact2); 00384 size = fact1 * fact2; 00385 00386 fprintf(stderr, "..%d..", size); 00387 00388 if (TIMING) startTimer(); 00389 pixDilateCompBrickDwa(pixt1, pixs, size, 1); 00390 pixDilateCompBrickDwa(pixt3, pixs, 1, size); 00391 pixDilateCompBrickDwa(pixt5, pixs, size, size); 00392 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00393 if (TIMING) startTimer(); 00394 pixDilateCompBrick(pixt2, pixs, size, 1); 00395 pixDilateCompBrick(pixt4, pixs, 1, size); 00396 pixDilateCompBrick(pixt6, pixs, size, size); 00397 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00398 PixCompareDwa(size, "dilate", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00399 00400 /* pixDisplay(pixt1, 100, 100); */ 00401 /* pixDisplay(pixt2, 800, 100); */ 00402 00403 if (TIMING) startTimer(); 00404 pixErodeCompBrickDwa(pixt1, pixs, size, 1); 00405 pixErodeCompBrickDwa(pixt3, pixs, 1, size); 00406 pixErodeCompBrickDwa(pixt5, pixs, size, size); 00407 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00408 if (TIMING) startTimer(); 00409 pixErodeCompBrick(pixt2, pixs, size, 1); 00410 pixErodeCompBrick(pixt4, pixs, 1, size); 00411 pixErodeCompBrick(pixt6, pixs, size, size); 00412 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00413 PixCompareDwa(size, "erode", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00414 00415 if (TIMING) startTimer(); 00416 pixOpenCompBrickDwa(pixt1, pixs, size, 1); 00417 pixOpenCompBrickDwa(pixt3, pixs, 1, size); 00418 pixOpenCompBrickDwa(pixt5, pixs, size, size); 00419 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00420 if (TIMING) startTimer(); 00421 pixOpenCompBrick(pixt2, pixs, size, 1); 00422 pixOpenCompBrick(pixt4, pixs, 1, size); 00423 pixOpenCompBrick(pixt6, pixs, size, size); 00424 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00425 PixCompareDwa(size, "open", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00426 00427 /* pixDisplay(pixt1, 100, 100); */ 00428 /* pixDisplay(pixt2, 800, 100); */ 00429 /* pixWrite("/tmp/junkpixt1.png", pixt1, IFF_PNG); */ 00430 /* pixWrite("/tmp/junkpixt2.png", pixt2, IFF_PNG); */ 00431 00432 if (TIMING) startTimer(); 00433 pixCloseCompBrickDwa(pixt1, pixs, size, 1); 00434 pixCloseCompBrickDwa(pixt3, pixs, 1, size); 00435 pixCloseCompBrickDwa(pixt5, pixs, size, size); 00436 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00437 if (TIMING) startTimer(); 00438 pixCloseSafeCompBrick(pixt2, pixs, size, 1); 00439 pixCloseSafeCompBrick(pixt4, pixs, 1, size); 00440 pixCloseSafeCompBrick(pixt6, pixs, size, size); 00441 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00442 PixCompareDwa(size, "close", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00443 00444 return 0; 00445 } 00446 00447 00448 /* dwa composite with morph non-composite */ 00449 l_int32 00450 DoComparisonDwa5(PIX *pixs, 00451 PIX *pixt1, 00452 PIX *pixt2, 00453 PIX *pixt3, 00454 PIX *pixt4, 00455 PIX *pixt5, 00456 PIX *pixt6, 00457 l_int32 isize) 00458 { 00459 l_int32 fact1, fact2, size; 00460 00461 selectComposableSizes(isize, &fact1, &fact2); 00462 size = fact1 * fact2; 00463 00464 fprintf(stderr, "..%d..", size); 00465 00466 if (TIMING) startTimer(); 00467 pixDilateCompBrickDwa(pixt1, pixs, size, 1); 00468 pixDilateCompBrickDwa(pixt3, pixs, 1, size); 00469 pixDilateCompBrickDwa(pixt5, pixs, size, size); 00470 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00471 if (TIMING) startTimer(); 00472 pixDilateBrick(pixt2, pixs, size, 1); 00473 pixDilateBrick(pixt4, pixs, 1, size); 00474 pixDilateBrick(pixt6, pixs, size, size); 00475 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00476 PixCompareDwa(size, "dilate", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00477 00478 /* pixDisplay(pixt1, 100, 100); */ 00479 /* pixDisplay(pixt2, 800, 100); */ 00480 00481 if (TIMING) startTimer(); 00482 pixErodeCompBrickDwa(pixt1, pixs, size, 1); 00483 pixErodeCompBrickDwa(pixt3, pixs, 1, size); 00484 pixErodeCompBrickDwa(pixt5, pixs, size, size); 00485 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00486 if (TIMING) startTimer(); 00487 pixErodeBrick(pixt2, pixs, size, 1); 00488 pixErodeBrick(pixt4, pixs, 1, size); 00489 pixErodeBrick(pixt6, pixs, size, size); 00490 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00491 PixCompareDwa(size, "erode", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00492 00493 if (TIMING) startTimer(); 00494 pixOpenCompBrickDwa(pixt1, pixs, size, 1); 00495 pixOpenCompBrickDwa(pixt3, pixs, 1, size); 00496 pixOpenCompBrickDwa(pixt5, pixs, size, size); 00497 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00498 if (TIMING) startTimer(); 00499 pixOpenBrick(pixt2, pixs, size, 1); 00500 pixOpenBrick(pixt4, pixs, 1, size); 00501 pixOpenBrick(pixt6, pixs, size, size); 00502 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00503 PixCompareDwa(size, "open", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00504 00505 if (TIMING) startTimer(); 00506 pixCloseCompBrickDwa(pixt1, pixs, size, 1); 00507 pixCloseCompBrickDwa(pixt3, pixs, 1, size); 00508 pixCloseCompBrickDwa(pixt5, pixs, size, size); 00509 if (TIMING) fprintf(stderr, "Time Dwa: %7.3f sec\n", stopTimer()); 00510 if (TIMING) startTimer(); 00511 pixCloseSafeBrick(pixt2, pixs, size, 1); 00512 pixCloseSafeBrick(pixt4, pixs, 1, size); 00513 pixCloseSafeBrick(pixt6, pixs, size, size); 00514 if (TIMING) fprintf(stderr, "Time Rop: %7.3f sec\n", stopTimer()); 00515 PixCompareDwa(size, "close", pixt1, pixt2, pixt3, pixt4, pixt5, pixt6); 00516 00517 return 0; 00518 } 00519 00520 00521 l_int32 00522 PixCompareDwa(l_int32 size, 00523 const char *type, 00524 PIX *pixt1, 00525 PIX *pixt2, 00526 PIX *pixt3, 00527 PIX *pixt4, 00528 PIX *pixt5, 00529 PIX *pixt6) 00530 { 00531 l_int32 same, fail; 00532 00533 fail = FALSE; 00534 pixEqual(pixt1, pixt2, &same); 00535 if (!same) { 00536 fail = TRUE; 00537 fprintf(stderr, "%s (%d, 1) not same\n", type, size); 00538 } 00539 pixEqual(pixt3, pixt4, &same); 00540 if (!same) { 00541 fail = TRUE; 00542 fprintf(stderr, "%s (1, %d) not same\n", type, size); 00543 } 00544 pixEqual(pixt5, pixt6, &same); 00545 if (!same) { 00546 fail = TRUE; 00547 fprintf(stderr, "%s (%d, %d) not same\n", type, size, size); 00548 } 00549 return fail; 00550 } 00551