Leptonica 1.68
C Image Processing Library

showedges.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  * showedges.c
00018  *
00019  *    Uses computation of half edge function, along with thresholding.
00020  */
00021 
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include "allheaders.h"
00025 
00026 #define   SMOOTH_WIDTH_1       2  /* must be smaller */
00027 #define   SMOOTH_WIDTH_2       4  /* must be larger */
00028 #define   THRESHOLD            5  /* low works best */
00029 
00030 
00031 main(int    argc,
00032      char **argv)
00033 {
00034 char        *infile, *outfile;
00035 l_int32      d;
00036 PIX         *pixs, *pixgr, *pixb;
00037 static char  mainName[] = "showedges";
00038 
00039     if (argc != 3)
00040         exit(ERROR_INT(" Syntax: showedges infile outfile", mainName, 1));
00041 
00042     infile = argv[1];
00043     outfile = argv[2];
00044 
00045     pixs = pixRead(infile);
00046     d = pixGetDepth(pixs);
00047     if (d != 8 && d != 32) 
00048         exit(ERROR_INT("d not 8 or 32 bpp", mainName, 1));
00049 
00050     pixgr = pixHalfEdgeByBandpass(pixs, SMOOTH_WIDTH_1, SMOOTH_WIDTH_1,
00051                                         SMOOTH_WIDTH_2, SMOOTH_WIDTH_2);
00052     pixb = pixThresholdToBinary(pixgr, THRESHOLD);
00053     pixInvert(pixb, pixb);
00054 /*    pixWrite("junkpixgr", pixgr, IFF_JFIF_JPEG); */
00055     pixWrite(outfile, pixb, IFF_PNG);
00056 
00057     exit(0);
00058 }
00059 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines