Main Page   Data Structures   File List   Data Fields   Globals  

nonmaxsuprx.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 performs non-maxima suppression in the x-direction           */
00008 /*                                                                            */
00009 /*----------------------------------------------------------------------------*/
00010 /*-Interface Information------------------------------------------------------*/
00011 void NONMAXSUPRX (
00012 IMAGE  *in,      /*  I   Pointer to the input image.                          */
00013 IMAGE  **out     /*  O   Address of a pointer to the output image             */
00014 /*----------------------------------------------------------------------------*/
00015 ) { register short i, j, k, n;
00016     char msg[SLEN];
00017         
00018 
00019     /* check input */
00020     if (!CHECKIMG(in)) {
00021         MESSAGE('E'," Can't identify image.");
00022         goto the_end;
00023     } else if (in->nbnd > 1) {
00024         MESSAGE('E'," Image must be single-band.");
00025         goto the_end;
00026     }
00027 
00028 
00029     /* create image of appropriate size */
00030     if (!CHECKIMG(*out)) GETMEM(in->nbnd,in->nlin,in->npix,out);
00031     if (!*out) goto the_end;
00032 
00033 
00034 
00035     /* perform non-maxima supression in the x-direction */
00036     for (j=0; j<in->nlin; j++) {
00037         for (k=0; k<in->npix; k++) {
00038 
00039             if ((k < 1)||(k > in->npix-2)) {
00040                 /* ignore any data at the left and right edges of the window */
00041                 (*out)->data[0][j][k] = 0.0;
00042             } else if (((k>0)&&(in->data[0][j][k-1] > in->data[0][j][k]))
00043                 || ((k<in->npix-1)&&(in->data[0][j][k+1] > in->data[0][j][k]))) {
00044                     /* Supress this non-maxima edge pixel */
00045                     (*out)->data[0][j][k] = 0.0;
00046             } else {
00047                 (*out)->data[0][j][k] = in->data[0][j][k];
00048             }
00049         }
00050     }
00051     
00052         
00053     the_end:
00054     /* if (TIMES) TIMING(T_EXIT); */
00055 }

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