midctexp_u2.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 /* ************************* midctexp_u2.c ********************************/
00020 /*                                                                        */
00021 /*       FILTRAGE MULTIDATE - DERNIERE ETAPE DU FILTRE DE DANIELA         */
00022 /*             DCT-1 SUR AXE TEMPOREL, EXP ET GAIN                        */
00023 /*                                                                        */
00024 /*  Derniere modif : E. TROUVE, 10/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 
00051 int main(int argc, char *argv[]){
00052 
00053   /* operateurs  */
00054   select_ima_t *pt_sel;
00055   save_ima_t *pt_sav;
00056   idctexp_t idc;
00057 
00058   /* main  */
00059   param par0, *ptp;      /* tete et pointeur pour la chaine de parametres */
00060   int n, N, n0, j, lectOK;
00061   
00062   /* images */
00063   imafl *pt_imdct;   /* bloc images des coef de DCT */
00064   imau2 *pt_imres;   /* bloc images finales */ 
00065 
00066 
00067 /* LECTURE PARAMETRES */
00068   param_debut(argc, argv, &par0); 
00069   ptp = &par0; 
00070 
00071   ptp = idctexp_lect(&idc, ptp, "Retour en temporel (DCT-1) et multiplicatif (exp) : ");
00072   N = idc.N;
00073 
00074   /* allocation des  tableaux de descripteurs */
00075   if( (pt_sel = (select_ima_t *)malloc(N*sizeof(select_ima_t))) == NULL ){
00076       printf("\n>>midctexp_u2: ERREUR allocation tableau descripteurs impossible\n");
00077       exit(1);
00078   }
00079   if( (pt_sav = (save_ima_t *)malloc(N*sizeof(save_ima_t))) == NULL ){
00080       printf("\n>>midctexp_u2: ERREUR allocation tableau descripteurs impossible\n");
00081       exit(1);
00082   }
00083 
00084   ptp = select_ima_lect(pt_sel, ptp, "premiere image coeff 0 de DCT (fl) :");
00085   ptp = save_ima_lect(pt_sav, ptp, "premiere image resultat (u2) :");
00086 
00087   param_fin(argc, argv, &par0);
00088 
00089   for(n=1; n<N; n++){
00090       pt_sel[n] = pt_sel[0];
00091       nom_image_suivante( pt_sel[n-1].nom, pt_sel[n].nom);
00092       pt_sav[n] = pt_sav[0];
00093       nom_image_suivante( pt_sav[n-1].nom, pt_sav[n].nom);
00094   }
00095 
00096 
00097 /* INITIALISATION  */
00098   /* allocation des tableaux de bloc images  */
00099   if( (pt_imres = (imau2 *)malloc(N*sizeof(imau2))) == NULL ){
00100       printf ("\n>>midctexp_u2: ERREUR allocation tableau image impossible\n");  
00101       exit(1);
00102   }  
00103   if( (pt_imdct = (imafl *)malloc(N*sizeof(imafl))) == NULL ){
00104       printf ("\n>>midctexp_u2: ERREUR allocation tableau image impossible\n");  
00105       exit(1);
00106   }  
00107 
00108   /* init lecture/ecriture */
00109   for(n=0; n<N; n++){
00110       select_imafl_init(pt_sel+n , pt_imdct+n);
00111       save_ima_init(pt_sav+n);
00112       pt_imres[n].p = NULL;    /* pour que l'allocation ait bien lieu */
00113   }
00114   idctexp_u2_init(&idc, pt_imdct, pt_imres);
00115 
00116 
00117 /* CALCUL */
00118   lectOK = 1;
00119   while( (select_imafl_calc(pt_sel, pt_imdct)==0) && (lectOK==1)){
00120       for(n=1; n<N; n++)
00121           if(select_imafl_calc(pt_sel+n, pt_imdct+n)){
00122               lectOK = 0;
00123               break;
00124           }
00125       if( lectOK == 0 ){
00126               printf("\n Pb lecture image %s : fin prematuree\n", pt_sel[n].nom);
00127               break;
00128       }
00129       idctexp_u2_calc(&idc, pt_imdct, pt_imres);
00130       for(n=0; n<N; n++)
00131           save_imau2_calc(pt_sav+n, pt_imres[n]);
00132   }
00133 
00134 
00135       
00136 /* FREMETURE */
00137   for(n=0; n<N; n++)
00138       save_ima_ferm(pt_sel[N-1], pt_sav[n]);
00139 
00140 }
00141 
00142 
00143 

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