mfiltmdate_dct.c

00001 /*
00002 *    Copyright (c) 2007. The BATI team. All right reserved.
00003 *
00004 *    This file is part of BATI library.
00005 *
00006 *    BATI library is free software: you can redistribute it and/or modify
00007 *    it under the terms of the GNU General Public License as published by
00008 *    the Free Software Foundation, either version 3 of the License, or
00009 *    (at your option) any later version.
00010 *
00011 *    BATI library  is distributed in the hope that it will be useful,
00012 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 *    GNU General Public License for more details.
00015 *
00016 *    You should have received a copy of the GNU General Public License
00017 *    along with BATI library.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 /* ************************** mfiltmdate_dct.c ****************************/
00020 /*                                                                        */
00021 /*   FILTRE MULTIDATE DE DANIELA COLCUC - VERSION GOURMANDE EN MEMOIRE    */
00022 /*   LOG, DCT SUR AXE TEMPOREL, FILTRE SPATIAL DES CANAUX, DCT-1, EXP     */
00023 /*                                                                        */
00024 /*  Derniere modif : E. TROUVE, 13/09/2000                                */
00025 /* ************************************************************************/
00026 #include <math.h>
00027 #include <limits.h>
00028 #include "image.h"
00029 #include "proto2D.h"
00030 #include "radar.h"
00031 /* #include "radar_comp.h" */
00032 
00059 int main(int argc, char *argv[]){
00060 
00061   /* operateurs  */
00062   read_ima_t *pt_rea;
00063   write_ima_t *pt_wri;
00064   logdct_t ld;
00065   idctexp_t idc;
00066   lee_add_t lee_add;
00067   moy2D_t  moy;
00068   moycarre2D_t  moycar;
00069 
00070   /* main  */
00071   param par0, *ptp;      /* tete et pointeur pour la chaine de parametres */
00072   int n, N, n0, j, lectOK;
00073   
00074   /* images */
00075   imau2 *pt_im0;       /* images initiales */ 
00076   imafl *pt_imdct;      /* images des coef de DCT */
00077   imafl moyamp, moycarre; /* pour accelerer le calcul du filtage spatial */ 
00078  
00079 
00080 /* LECTURE PARAMETRES */
00081   param_debut(argc, argv, &par0); 
00082   ptp = &par0; 
00083 
00084   ptp = idctexp_lect(&idc, ptp, "Filtrage multidate dans l'espace transforme (DCT) : ");
00085   N = idc.N;
00086   ld.N = N;     /* operateur logdct, lecture inutile, N deja connu */
00087 
00088   /* allocation des  tableaux de descripteurs */
00089   if( (pt_rea = (read_ima_t *)malloc(N*sizeof(read_ima_t))) == NULL ){
00090       printf("\n>>mfiltmdate_dct: ERREUR allocation tableau descripteurs impossible\n");
00091       exit(1);
00092   }
00093   if( (pt_wri = (write_ima_t *)malloc(N*sizeof(write_ima_t))) == NULL ){
00094       printf("\n>>mfiltmdate_dct: ERREUR allocation tableau descripteurs impossible\n");
00095       exit(1);
00096   }
00097 
00098   ptp = read_ima_lect(pt_rea, ptp, "premiere image initiale (u2) :");
00099   ptp = write_ima_lect(pt_wri, ptp, "premiere image resultat (u2) :");
00100 
00101   ptp = lee_add_lect(&lee_add, ptp, "Filtrage spatial des canaux frequentiels (Lee_Add) :");
00102   moy.dimX = lee_add.dimX;     moy.dimY = lee_add.dimY;    /* operateur moy2D */
00103   moycar.dimX = lee_add.dimX;  moycar.dimY = lee_add.dimY; /* operateur moycarre2D */
00104 
00105   param_fin(argc, argv, &par0);
00106 
00107   for(n=1; n<N; n++){
00108       pt_rea[n] = pt_rea[0];
00109       nom_image_suivante( pt_rea[n-1].nom, pt_rea[n].nom);
00110       pt_wri[n] = pt_wri[0];
00111       nom_image_suivante( pt_wri[n-1].nom, pt_wri[n].nom);
00112   }
00113 
00114 
00115 /* INITIALISATION  */
00116   /* allocation des tableaux de bloc images  */
00117   if( (pt_im0 = (imau2 *)malloc(N*sizeof(imau2))) == NULL ){
00118       printf ("\n>>mfiltmdate_dct: ERREUR allocation tableau image impossible\n");  
00119       exit(1);
00120   }  
00121   if( (pt_imdct = (imafl *)malloc(N*sizeof(imafl))) == NULL ){
00122       printf ("\n>>mfiltmdate_dct: ERREUR allocation tableau image impossible\n");  
00123       exit(1);
00124   }  
00125 
00126   /* init lecture/ecriture */
00127   for(n=0; n<N; n++){
00128       read_imau2_init(pt_rea+n , pt_im0+n);
00129       write_ima_init(pt_wri+n);
00130   }
00131 
00132   /* transfo, filtre spatial, transfo inverse */
00133   logdct_u2_init(&ld, pt_im0, pt_imdct);
00134   moy2Dfl_init(&moy, pt_imdct[0], &moyamp);
00135   moycarre2Dfl_init(&moycar, pt_imdct[0], &moycarre);
00136   /* lee_addfl_init inutil : le resutat est calcule dans l'image initiale  */
00137   idctexp_u2_init(&idc, pt_imdct, pt_im0); /* resultat dans images inititiales */
00138 
00139 /* CALCUL */
00140   logdct_u2_calc(&ld, pt_im0, pt_imdct);
00141   for(n=1; n<N; n++){ /* filtrage spatial des canaux de DCT sauf le canal 0 */
00142       moy2Dfl_calc(&moy, pt_imdct[n], &moyamp);
00143       moycarre2Dfl_calc(&moycar, pt_imdct[n], &moycarre);
00144       lee_addfl_calc(&lee_add, pt_imdct[n], moyamp, moycarre, pt_imdct+n);  
00145   }
00146   idctexp_u2_calc(&idc, pt_imdct, pt_im0);
00147       
00148 /* FREMETURE */
00149   for(n=0; n<N; n++)
00150       write_imau2_ferm(pt_wri+n, pt_im0[n]);
00151 
00152 }
00153 
00154 
00155 

Generated on Tue Apr 22 13:31:04 2008 for ima2D by  doxygen 1.5.3