Main Page   Data Structures   File List   Data Fields   Globals  

bingrid.c

Go to the documentation of this file.
00001 #include "sadie.h"
00002 #include "proto.h"
00003 
00004 /*----------------------------------------------------------------------------*/
00005 /*-General Information--------------------------------------------------------*/
00006 /*                                                                            */
00007 /*   This function produces a grid on the input binary image.                 */
00008 /*                                                                            */
00009 /*----------------------------------------------------------------------------*/
00010 /*-Interface Information------------------------------------------------------*/
00011 void BINGRID (
00012 IMAGE  *in,      /*  I   Pointer to the input image.                           */
00013 IMAGE  **out     /*  O   Address of a pointer to the output image             */
00014 /*----------------------------------------------------------------------------*/
00015 ) { register int i, j, k, m, n;
00016     char msg[SLEN];
00017     int pixsize = 5;
00018 
00019     /* if (TIMES) TIMING(T_BINGRID); */
00020     if (NAMES) {
00021         MESSAGE('I',"");
00022         MESSAGE('I',"BINGRID");
00023         MESSAGE('I',"");
00024         sprintf(msg," Input image:                       %s",in->text);
00025         MESSAGE('I',msg);
00026         MESSAGE('I'," ...............");
00027     }
00028 
00029     /* check input */
00030     if (!CHECKIMG(in)) {
00031         MESSAGE('E'," Can't identify image.");
00032         goto the_end;
00033     } else if (in->nlin > 100 || in->npix > 100 || in->nbnd > 1) {
00034         MESSAGE('E'," Image must be single band, smaller than 100x100.");
00035         goto the_end;
00036     }
00037     
00038     RANGE(in);
00039 
00040 
00041     /* create output image of appropriate size */
00042     if (!CHECKIMG(*out)) GETMEM(1,(in->nlin * pixsize)+1,(in->npix * pixsize)+1,out);
00043     if (!*out) goto the_end;
00044 
00045     /* set background to black */
00046     for (j=0; j<(in->nlin * pixsize)+1; j++) {
00047         for (k=0; k<(in->npix * pixsize)+1; k++) {
00048             (*out)->data[0][j][k] = (PIXEL)0.0;
00049         }
00050     }
00051 
00052     /* insert binary data */
00053     for (j=0; j<in->nlin; j++) {
00054         for (k=0; k<in->npix; k++) {
00055             if (in->data[0][j][k] > in->gmin) {
00056                 for (m=1; m<pixsize; m++) {
00057                     for (n=1; n<pixsize; n++) {
00058                         (*out)->data[0][(j*pixsize)+m][(k*pixsize)+n] = (PIXEL)1.0;
00059                     }
00060                 }
00061             } else {
00062                 for (m=1; m<pixsize; m++) {
00063                     for (n=1; n<pixsize; n++) {
00064                         (*out)->data[0][(j*pixsize)+m][(k*pixsize)+n] = (PIXEL)2.0;
00065                     }
00066                 }
00067             }
00068         }
00069     }
00070         
00071     the_end:
00072     /* if (TIMES) TIMING(T_EXIT); */
00073 }

Generated on Wed Apr 9 08:56:03 2003 for TREES by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002