Main Page   Data Structures   File List   Data Fields   Globals  

trim.c

Go to the documentation of this file.
00001 #include        "sadie.h"
00002 #include        "trees.h"
00003 
00004 /*-General Information--------------------------------------------------------*/
00005 /*                                                                            */
00006 /*  Description:  This procedure trims an image.                                                       */
00007 /*                                                                            */
00008 /*----------------------------------------------------------------------------*/
00009 /*-Interface Information------------------------------------------------------*/
00010 void TRIM (
00011 IMAGE  *in,     /*  I   Pointer to the input image.                           */
00012 short    trimwidth,
00013 IMAGE  **out    /*  O   Address of a pointer to the output image.             */
00014 /*----------------------------------------------------------------------------*/
00015 ) { register short j, k;
00016     char   msg[SLEN];
00017 
00018     /* check input */
00019     if (!CHECKIMG(in)) {
00020         MESSAGE('E'," Can't identify image.");
00021         goto the_end;
00022     } else if (in->nbnd > 1) {
00023         MESSAGE('E'," Input image must be single band.");
00024         goto the_end;
00025     } else if (2*trimwidth >= in->npix || 2*trimwidth >= in->nlin) {
00026         MESSAGE('E'," Trim width is too large for image size.");
00027         goto the_end;
00028     }
00029 
00030 
00031     /* if (TIMES) TIMING(T_SIZEFILTER); */
00032     if (NAMES) {
00033         MESSAGE('I',"");
00034         MESSAGE('I',"TRIM");
00035         MESSAGE('I',"");
00036         sprintf(msg," Input image:                      %s",in->text);
00037         MESSAGE('I',msg);
00038         sprintf(msg," Trim width:                   %d",trimwidth);
00039         MESSAGE('I',msg);
00040         MESSAGE('I'," ...............");
00041     }
00042 
00043     
00044 
00045     /* create output image of appropriate size */
00046     if (!CHECKIMG(*out)) GETMEM(1,in->nlin-(2*trimwidth),in->npix-(2*trimwidth),out);
00047     if (!*out) goto the_end;
00048 
00049 
00050     /* Create the output image */
00051     for (j=trimwidth; j<in->nlin-trimwidth; j++) {
00052         for (k=trimwidth; k<in->npix-trimwidth; k++) {
00053             (*out)->data[0][j-trimwidth][k-trimwidth] = in->data[0][j][k];
00054         }
00055     }
00056 
00057 
00058     the_end:
00059 
00060     /* if (TIMES)   TIMING(T_EXIT); */
00061     return;
00062 }

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