mfiltmdate_moyt.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_moyt.c ***************************/
00020 /*                                                                        */
00021 /*       FILTRAGE MULTIDATE - MOYENNE TEMPORELLE                          */
00022 /*                                                                        */
00023 /*  Derniere modif : E. TROUVE, 10/09/2000                                */
00024 /* ************************************************************************/
00025 #include <math.h>
00026 #include <limits.h>
00027 #include "image.h"
00028 #include "proto2D.h"
00029 #include "radar.h"
00030 
00050 int main(int argc, char *argv[]){
00051 
00052   /* operateurs */
00053   read_ima_t  rea;
00054   write_ima_t wri;
00055 
00056   /* main */
00057   param par0, *ptp;      /* tete et pointeur pour la chaine de parametres */
00058   char nomtmp[200];
00059   int n, N, n0, i, nbp;
00060   pixu2 *ptim0;
00061   pixfl *ptsom;  
00062   float carre[65536];
00063 
00064   /* images */
00065   imau2 im0;  /* images initiales, puis resultat */ 
00066   imafl som;   /* somme des images elevees au carre */
00067 
00068 
00069 /* LECTURE PARAMETRES */
00070   param_debut(argc, argv, &par0); 
00071   ptp = &par0; 
00072 
00073   lec_param("Moyenne temporelle d'une serie d'images : nombre d'images", ptp);
00074   N = atoi(ptp->rep);
00075   ptp = ptp->next;
00076 
00077   ptp = read_ima_lect(&rea, ptp, "Premiere image initiale (u2) :");
00078 
00079   ptp = write_ima_lect(&wri, ptp, "Images resultat (u2) :");
00080 
00081   param_fin(argc, argv, &par0);
00082 
00083 
00084 /* INITIALISATION - CALCUL */
00085   for(i=0; i<65536; i++)
00086       carre[i] = (float)i*(float)i;
00087 
00088   write_ima_init(&wri);
00089 
00090   /* lecture, moyennage  des images */
00091   for(n=0; n<N; n++){
00092       if(n>0){
00093           nom_image_suivante(rea.nom, nomtmp);
00094           strcpy(rea.nom, nomtmp);
00095       }
00096       read_imau2_init(&rea, &im0);
00097 
00098       ptim0 = im0.p[0];
00099       if(n==0){
00100           som.nr = im0.nr;
00101           som.nc = im0.nc;
00102           alloc_imafl(&som);
00103           ptsom = som.p[0];
00104           nbp = im0.nr*im0.nc;
00105           for( i=0; i<nbp; i++)
00106               ptsom[i] = carre[ptim0[i]];
00107       }
00108       else{
00109           for( i=0; i<nbp; i++)
00110               ptsom[i] += carre[ptim0[i]];
00111       }
00112 
00113       if( n < N-1){
00114           free_imau2(&im0);
00115       }
00116   }
00117   for( i=0; i<nbp; i++)
00118       ptim0[i] = (pixu2)sqrt((double)(ptsom[i]/N));
00119       
00120 /* FREMETURE */
00121   write_imau2_ferm(&wri, im0);
00122 }
00123 
00124 
00125 

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