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 /* 00018 * cornertest.c 00019 * 00020 * e.g., use on witten.tif 00021 */ 00022 00023 #include <stdio.h> 00024 #include <stdlib.h> 00025 #include "allheaders.h" 00026 00027 #define LINE_SIZE 9 00028 00029 00030 main(int argc, 00031 char **argv) 00032 { 00033 char *filein, *fileout; 00034 l_int32 x, y, n, i; 00035 PIX *pixs; 00036 PTA *pta; 00037 PTAA *ptaa, *ptaa2, *ptaa3; 00038 static char mainName[] = "cornertest"; 00039 00040 if (argc != 3) 00041 exit(ERROR_INT(" Syntax: cornertest filein fileout", mainName, 1)); 00042 00043 filein = argv[1]; 00044 fileout = argv[2]; 00045 00046 if ((pixs = pixRead(filein)) == NULL) 00047 exit(ERROR_INT("pixs not made", mainName, 1)); 00048 00049 /* Clean noise in LR corner of witten.tif */ 00050 pixSetPixel(pixs, 2252, 3051, 0); 00051 pixSetPixel(pixs, 2252, 3050, 0); 00052 pixSetPixel(pixs, 2251, 3050, 0); 00053 00054 pta = pixFindCornerPixels(pixs); 00055 ptaWriteStream(stderr, pta, 1); 00056 00057 /* Test pta and ptaa I/O */ 00058 #if 1 00059 ptaa = ptaaCreate(3); 00060 ptaaAddPta(ptaa, pta, L_COPY); 00061 ptaaAddPta(ptaa, pta, L_COPY); 00062 ptaaAddPta(ptaa, pta, L_COPY); 00063 ptaaWriteStream(stderr, ptaa, 1); 00064 ptaaWrite("/tmp/junkptaa", ptaa, 1); 00065 ptaa2 = ptaaRead("/tmp/junkptaa"); 00066 ptaaWrite("/tmp/junkptaa2", ptaa2, 1); 00067 ptaaWrite("/tmp/junkptaa3", ptaa, 0); 00068 ptaa3 = ptaaRead("/tmp/junkptaa3"); 00069 ptaaWrite("/tmp/junkptaa4", ptaa3, 0); 00070 ptaaDestroy(&ptaa); 00071 ptaaDestroy(&ptaa2); 00072 ptaaDestroy(&ptaa3); 00073 #endif 00074 00075 /* mark corner pixels */ 00076 n = ptaGetCount(pta); 00077 for (i = 0; i < n; i++) { 00078 ptaGetIPt(pta, i, &x, &y); 00079 pixRenderLine(pixs, x - LINE_SIZE, y, x + LINE_SIZE, y, 3, 00080 L_FLIP_PIXELS); 00081 pixRenderLine(pixs, x, y - LINE_SIZE, x, y + LINE_SIZE, 3, 00082 L_FLIP_PIXELS); 00083 } 00084 00085 pixWrite(fileout, pixs, IFF_PNG); 00086 00087 pixDestroy(&pixs); 00088 ptaDestroy(&pta); 00089 ptaDestroy(&pta); 00090 00091 exit(0); 00092 } 00093