00001 #include "trees.h"
00002 #include "histogram.h"
00003 #include <sys/time.h>
00004
00005
00006
00007
00008
00009
00010
00011
00012 void MOSAIC_BYTE_SUPPRESS (
00013 IMAGE_BYTE *in,
00014 MOSAIC_INDEX *index,
00015 IMAGE_BYTE *iMag,
00016 IMAGE_BYTE *iDir,
00017 HISTOGRAM *ghist,
00018 HISTOGRAM ***lhist
00019
00020 ) { register int i, j, k;
00021 int nrows, ncols;
00022 HISTOGRAM globalhist;
00023 HISTOGRAM **localhist;
00024 struct timeval start, end;
00025
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
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
00052 localhist = (HISTOGRAM **)MATRIX(nrows, ncols, 0, 0, sizeof(HISTOGRAM));
00053
00054
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
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
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
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
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
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
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 }