1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
- This software is distributed in the hope that it will be
- useful, but with NO WARRANTY OF ANY KIND.
- No author or distributor accepts responsibility to anyone for the
- consequences of using this software, or for whether it serves any
- particular purpose or works at all, unless he or she says so in
- writing. Everyone is granted permission to copy, modify and
- redistribute this source code, for commercial or non-commercial
- purposes, with the following restrictions: (1) the origin of this
- source code must not be misrepresented; (2) modified versions must
- be plainly marked as such; and (3) this notice may not be removed
- or altered from any source or modified source distribution.
*====================================================================*/
/*
* threshnorm__reg.c
*
* Regression test for adaptive threshold normalization.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "allheaders.h"
static void AddTestSet(PIXA *pixa, PIX *pixs,
l_int32 filtertype, l_int32 edgethresh,
l_int32 smoothx, l_int32 smoothy,
l_float32 gamma, l_int32 minval,
l_int32 maxval, l_int32 targetthresh);
main(int argc,
char **argv)
{
PIX *pixs, *pixd;
PIXA *pixa;
static char mainName[] = "threshnorm_reg";
if (argc != 1)
exit(ERROR_INT(" Syntax: threshnorm_reg", mainName, 1));
if ((pixs = pixRead("stampede2.jpg")) == NULL)
exit(ERROR_INT("pixs not made", mainName, 1));
pixa = pixaCreate(0);
pixSaveTiled(pixs, pixa, 1, 1, 20, 8);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 18, 40, 40, 0.7, -25, 280, 128);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 18, 40, 40, 0.7, -25, 280, 128);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 10, 40, 40, 0.7, -15, 305, 128);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 10, 40, 40, 0.7, -15, 305, 128);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 15, 40, 40, 0.6, -45, 285, 158);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 15, 40, 40, 0.6, -45, 285, 158);
pixDestroy(&pixs);
pixd = pixaDisplay(pixa, 0, 0);
pixDisplay(pixd, 100, 100);
pixWrite("junkpixd", pixd, IFF_JFIF_JPEG);
pixDestroy(&pixd);
pixaDestroy(&pixa);
return 0;
}
void
AddTestSet(PIXA *pixa,
PIX *pixs,
l_int32 filtertype,
l_int32 edgethresh,
l_int32 smoothx,
l_int32 smoothy,
l_float32 gamma,
l_int32 minval,
l_int32 maxval,
l_int32 targetthresh)
{
PIX *pixb, *pixd, *pixth;
pixThresholdSpreadNorm(pixs, filtertype, edgethresh,
smoothx, smoothy, gamma, minval,
maxval, targetthresh, &pixth, NULL, &pixd);
pixSaveTiled(pixth, pixa, 1, 1, 20, 0);
pixSaveTiled(pixd, pixa, 1, 0, 20, 0);
pixb = pixThresholdToBinary(pixd, targetthresh - 20);
pixSaveTiled(pixb, pixa, 1, 0, 20, 0);
pixDestroy(&pixb);
pixb = pixThresholdToBinary(pixd, targetthresh);
pixSaveTiled(pixb, pixa, 1, 0, 20, 0);
pixDestroy(&pixb);
pixb = pixThresholdToBinary(pixd, targetthresh + 20);
pixSaveTiled(pixb, pixa, 1, 0, 20, 0);
pixDestroy(&pixb);
pixb = pixThresholdToBinary(pixd, targetthresh + 40);
pixSaveTiled(pixb, pixa, 1, 0, 20, 0);
pixDestroy(&pixb);
pixDestroy(&pixth);
pixDestroy(&pixd);
return;
}
|