Main Page   Data Structures   File List   Data Fields   Globals  

mosaic_byte_suppress.c

Go to the documentation of this file.
00001 #include "trees.h"
00002 #include "histogram.h"
00003 #include <sys/time.h>
00004 
00005 /*-General Information--------------------------------------------------------*/
00006 /*                                                                            */
00007 /*  Description:  This procedure returns gradient magnitude and direction     */
00008 /*                mosaics of prospective edge pixels.                         */
00009 /*                                                                            */
00010 /*----------------------------------------------------------------------------*/
00011 /*-Interface Information------------------------------------------------------*/
00012 void MOSAIC_BYTE_SUPPRESS (
00013 IMAGE_BYTE  *in,       /*  I   Pointer to the input mosaic image.             */
00014 MOSAIC_INDEX  *index,  /*  I   Pointer to the input mosaic index.             */
00015 IMAGE_BYTE  *iMag,     /*  I/O Pointer to the magnitude mosaic.               */
00016 IMAGE_BYTE  *iDir,      /*  I/O Pointer to the direction mosaic.               */
00017 HISTOGRAM  *ghist,     /*  O   Pointer to the global histogram.               */ 
00018 HISTOGRAM  ***lhist    /*  O   Pointer to the local histogram.                */
00019 /*----------------------------------------------------------------------------*/
00020 ) { register int i, j, k;
00021     int nrows, ncols;
00022     HISTOGRAM globalhist;
00023     HISTOGRAM **localhist;
00024     struct timeval start, end;
00025     /* check input */
00026     if (!CHECKIMG_BYTE(in)) {
00027         MESSAGE('E'," Can't identify mosaic image.");
00028         goto the_end;
00029     } else if (!CHECKIMG_MOSAIC_INDEX(index)) {
00030         MESSAGE('E'," Can't identify mosaic index.");
00031         goto the_end;
00032     } else if (!CHECKIMG_BYTE(iMag)) {
00033         MESSAGE('E'," Can't identify mosaic image: gradient.");
00034         goto the_end;
00035     } else if (!CHECKIMG_BYTE(iDir)) {
00036         MESSAGE('E'," Can't identify mosaic image: direction.");
00037         goto the_end;
00038     } else if(in->nlin != iMag->nlin || in->nlin != iDir->nlin ||
00039               in->npix != iMag->npix || in->npix != iDir->npix) {
00040         MESSAGE('E'," Size of mosaics differ.");
00041         goto the_end;
00042     }
00043 
00044     
00045     /* Determine the number of blocks needed to cover the ROI */
00046     nrows = index->roi->bottom[0] - index->roi->top[0] + 1;
00047     ncols = index->hend - index->hstart + 1;
00048     nrows = ceil((double)nrows/HIST_BLOCK_DIM);
00049     ncols = ceil((double)ncols/HIST_BLOCK_DIM);
00050 
00051     /* Allocate memory */
00052     localhist = (HISTOGRAM **)MATRIX(nrows, ncols, 0, 0, sizeof(HISTOGRAM));
00053 
00054     /* Initialize histograms */
00055     HIST_INIT(&globalhist);
00056     for(i = 0; i < nrows; i++)
00057         for(j = 0; j < ncols; j++)
00058             HIST_INIT(localhist[i]+j);
00059 
00060     /* Compute magnitude histogram */
00061     gettimeofday(&start, NULL);
00062     HIST_MAG(iMag, index, &globalhist, localhist, nrows, ncols);
00063     gettimeofday(&end, NULL);
00064     printf("    magnitude histogram = %ld ms.\n", delay(start, end));
00065 
00066     /* Compute the Rth percentile of magnitude histogram */
00067     gettimeofday(&start, NULL);
00068     HIST_RTH_PERCENTILE(&globalhist, localhist, MAG_PERCENTILE, nrows, ncols);
00069     gettimeofday(&end, NULL);
00070     printf("    compute Rth percentile = %ld ms.\n", delay(start, end));
00071 
00072     /* Compute direction histogram */
00073     gettimeofday(&start, NULL);
00074     HIST_DIR(iMag, iDir, index, &globalhist, localhist, nrows, ncols);
00075     gettimeofday(&end, NULL);
00076     printf("    direction histogram = %ld ms.\n", delay(start, end));
00077         
00078     /* Global & local orientation */
00079     gettimeofday(&start, NULL);
00080     HIST_ORIENTATION(&globalhist, localhist, nrows, ncols);
00081     gettimeofday(&end, NULL);
00082     printf("    compute ring orientation = %ld ms.\n", delay(start, end));
00083 
00084     /* Resolve gradient direction in the blocks */
00085     gettimeofday(&start, NULL);
00086     HIST_RESOLVE(&globalhist, localhist, nrows, ncols);
00087     gettimeofday(&end, NULL);
00088     printf("    resolve ring orientation = %ld ms.\n", delay(start, end));
00089 
00090     /* Suppress non-edge pixels */
00091     gettimeofday(&start, NULL);
00092     HIST_SUPPRESS(iMag, iDir, index, localhist);
00093     gettimeofday(&end, NULL);
00094     printf("    suppress non-edge pixels = %ld ms.\n", delay(start, end));
00095 
00096     for(k = index->hstart; k <= index->hend; k++) {
00097         iMag->data[0][index->vstart[k] - index->voffset[k]][k] = 0;
00098         iMag->data[0][index->vend[k] - index->voffset[k]][k] = 0;
00099     }
00100 
00101     ghist = &globalhist;
00102     lhist = &localhist;
00103     
00104     the_end:
00105 }

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