Leptonica 1.68
C Image Processing Library

pixadisp_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  *   pixadisp_reg.c
00018  *
00019  *     Exercises various pixaDisplay*() functions.
00020  *
00021  *     Syntax:  pixadisp_reg
00022  */
00023 
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include "allheaders.h"
00027 
00028 
00029 main(int    argc,
00030      char **argv)
00031 {
00032 l_int32      ws, hs;
00033 BOX         *box;
00034 BOXA        *boxa;
00035 PIX         *pixs, *pixc, *pix32, *pixt, *pixd;
00036 PIXA        *pixat, *pixas, *pixac;
00037 static char  mainName[] = "pixadisp_reg";
00038 
00039     if (argc != 1)
00040         exit(ERROR_INT(" Syntax: pixadisp_reg", mainName, 1));
00041 
00042     if ((pixs = pixRead("feyn.tif")) == NULL)
00043         exit(ERROR_INT("pixs not made", mainName, 1));
00044     box = boxCreate(683, 799, 970, 479);
00045     pixc = pixClipRectangle(pixs, box, NULL);
00046     boxDestroy(&box);
00047     pixDisplayWrite(pixc, 1);
00048     if ((pix32 = pixRead("marge.jpg")) == NULL)
00049         exit(ERROR_INT("pix32 not made", mainName, 1));
00050 
00051         /* Generate pixas from pixs and pixac from pixc */
00052     boxa = pixConnComp(pixs, &pixat, 8);
00053     pixas = pixaSelectBySize(pixat, 60, 60, L_SELECT_IF_BOTH,
00054                              L_SELECT_IF_LTE, NULL);
00055     pixaDestroy(&pixat);
00056     boxaDestroy(&boxa);
00057     boxa = pixConnComp(pixc, &pixac, 8);
00058     boxaDestroy(&boxa);
00059  
00060         /* pixaDisplay() */
00061     pixGetDimensions(pixs, &ws, &hs, NULL);
00062     pixd = pixaDisplay(pixas, ws, hs);
00063     pixDisplayWrite(pixd, 1);
00064     pixDestroy(&pixd);
00065 
00066         /* pixaDisplayRandomCmap() */
00067     pixd = pixaDisplayRandomCmap(pixas, ws, hs);  /* black bg */
00068     pixDisplayWrite(pixd, 1);
00069     pixcmapResetColor(pixGetColormap(pixd), 0, 255, 255, 255);  /* white bg */
00070     pixDisplayWrite(pixd, 1);
00071     pixDestroy(&pixd);
00072 
00073         /* pixaDisplayOnLattice() */
00074     pixd = pixaDisplayOnLattice(pixac, 50, 50);
00075     pixDisplayWrite(pixd, 1);
00076     pixDestroy(&pixd);
00077 
00078         /* pixaDisplayUnsplit() */
00079     pixat = pixaSplitPix(pix32, 5, 7, 10, 0x0000ff00);
00080     pixd = pixaDisplayUnsplit(pixat, 5, 7, 10, 0x00ff0000);
00081     pixDisplayWrite(pixd, 1);
00082     pixaDestroy(&pixat);
00083     pixDestroy(&pixd);
00084 
00085         /* pixaDisplayTiled() */
00086     pixd = pixaDisplayTiled(pixac, 1000, 0, 10);
00087     pixDisplayWrite(pixd, 1);
00088     pixDestroy(&pixd);
00089 
00090         /* pixaDisplayTiledInRows() */
00091     pixd = pixaDisplayTiledInRows(pixac, 1, 1000, 1.0, 0, 10, 2);
00092     pixDisplayWrite(pixd, 1);
00093     pixDestroy(&pixd);
00094 
00095 
00096         /* pixaDisplayTiledAndScaled() */
00097     pixd = pixaDisplayTiledAndScaled(pixac, 1, 25, 20, 0, 5, 0);
00098     pixDisplayWrite(pixd, 1);
00099     pixDestroy(&pixd);
00100 
00101     pixat = pixaCreate(10);
00102     pixd = pixRankFilter(pix32, 8, 8, 0.5);
00103     pixaAddPix(pixat, pixd, L_INSERT);
00104     pixt = pixScale(pix32, 0.5, 0.5);
00105     pixd = pixRankFilter(pixt, 8, 8, 0.5);
00106     pixaAddPix(pixat, pixd, L_INSERT);
00107     pixDestroy(&pixt);
00108     pixt = pixScale(pix32, 0.25, 0.25);
00109     pixd = pixRankFilter(pixt, 8, 8, 0.5);
00110     pixaAddPix(pixat, pixd, L_INSERT);
00111     pixDestroy(&pixt);
00112     pixd = pixaDisplayTiledAndScaled(pixat, 32, 500, 1, 0, 25, 0);
00113     pixDisplayWrite(pixd, 1);
00114     pixaDestroy(&pixat);
00115     pixDestroy(&pixd);
00116 
00117     pixaDestroy(&pixas);
00118     pixaDestroy(&pixac);
00119     pixDestroy(&pixs);
00120     pixDestroy(&pixc);
00121     pixDestroy(&pix32);
00122 
00123     pixDisplayMultiple("/tmp/junk_write_display*");
00124     return 0;
00125 }
00126 
00127 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines