00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <math.h>
00026 #include <limits.h>
00027 #include "image.h"
00028 #include "proto2D.h"
00029 #include "radar.h"
00030
00053 int main(int argc, char *argv[]){
00054
00055
00056 read_ima_t rea;
00057 moy2D_t dmoy;
00058 moycarre2D_t dcarre;
00059 kuan_t dkuan;
00060 write_ima_t *tabwri;
00061
00062
00063 param par0, *ptp;
00064 char nomtmp[200];
00065 pixu2 *pt0;
00066 int n, N, i, j, k, dimX, dimY, nbp, texture;
00067 pixfl *ptim2, *ptf2D, *ptsom, *ptcarre;
00068 pixfl tab2[65536];
00069 double tmpdb;
00070
00071
00072 imau2 im0;
00073 imafl *tabim2;
00074 imafl imf2D;
00075 imafl imcarre;
00076 imafl imsom;
00077
00078
00079
00080 param_debut(argc, argv, &par0);
00081 ptp = &par0;
00082
00083 lec_param("Filtre multidates de Bruniquel simplifie (1/N) : nombre d'images", ptp);
00084 N = atoi(ptp->rep);
00085 ptp = ptp->next;
00086
00087 lec_param("Filtrage avec compensation des moyennes (0) ou des textures (1)", ptp);
00088 texture = atoi(ptp->rep);
00089 ptp = ptp->next;
00090
00091 ptp = kuan_lect(&dkuan, ptp, "Fenetre de filtrage spatial :");
00092
00093 ptp = read_ima_lect(&rea, ptp, "Premiere image initiale (u2) :");
00094
00095 if( (tabwri = (write_ima_t *)malloc(N*sizeof(write_ima_t))) == NULL ){
00096 printf ("\n allocation tableau descripteurs impossible\n");
00097 exit(1);
00098 }
00099 ptp = write_ima_lect(tabwri, ptp, "Premiere image resultat (u2) :");
00100 for(n=1; n<N; n++){
00101 tabwri[n] = tabwri[0];
00102 nom_image_suivante( tabwri[n-1].nom, tabwri[n].nom);
00103 }
00104
00105 param_fin(argc, argv, &par0);
00106
00107
00108 if( (tabim2 = (imafl *)malloc(N*sizeof(imafl))) == NULL ){
00109 printf ("\n allocation tableau image impossible\n");
00110 exit(1);
00111 }
00112
00113
00114 for(j=0; j<65536; j++)
00115 tab2[j] = (pixfl)(j*j);
00116 for(n=0; n<N; n++){
00117 if(n>0){
00118 nom_image_suivante(rea.nom, nomtmp);
00119 strcpy(rea.nom, nomtmp);
00120 }
00121 read_imau2_init(&rea, &im0);
00122 pt0 = im0.p[0];
00123 if(n==0)
00124 nbp = im0.nc*im0.nr;
00125 else{
00126 if (im0.nc*im0.nr != nbp ){
00127 printf ("\n dimension image %s incoherente avec les precedentes\n", rea.nom);
00128 exit(1);
00129 }
00130 }
00131
00132 tabim2[n].nr = im0.nr;
00133 tabim2[n].nc = im0.nc;
00134 alloc_imafl(tabim2+n);
00135 ptim2 = tabim2[n].p[0];
00136 for(k=0; k<nbp; k++)
00137 ptim2[k] = tab2[pt0[k]];
00138 if(n<N-1)
00139 free_imau2(&im0);
00140 write_ima_init(tabwri+n);
00141 }
00142
00143
00144 dmoy.dimX = dkuan.dimX;
00145 dmoy.dimY = dkuan.dimY;
00146 moy2Dfl_init(&dmoy, tabim2[0], &imf2D);
00147 ptf2D = imf2D.p[0];
00148 if(texture){
00149 dcarre.dimX = dkuan.dimX;
00150 dcarre.dimY = dkuan.dimY;
00151 moycarre2Dfl_init(&dcarre, tabim2[0], &imcarre);
00152 ptcarre = imcarre.p[0];
00153
00154 }
00155
00156
00157 imsom.nc = imf2D.nc;
00158 imsom.nr = imf2D.nr;
00159 alloc_imafl(&imsom);
00160 ptsom = imsom.p[0];
00161 for(k=0; k<nbp; k++)
00162 ptsom[k] = 0.;
00163
00164
00165 for(n=0; n<N; n++){
00166 ptim2 = tabim2[n].p[0];
00167
00168 moy2Dfl_calc(&dmoy, tabim2[n], &imf2D);
00169 if(texture){
00170 moycarre2Dfl_calc(&dcarre, tabim2[n], &imcarre);
00171 kuanfl_calc(&dkuan, tabim2[n], imf2D, imcarre, &imf2D);
00172 }
00173 for(k=0; k<nbp; k++){
00174 ptsom[k] += ptim2[k]/ptf2D[k];
00175 ptim2[k] = ptf2D[k];
00176 }
00177 }
00178 for(k=0; k<nbp; k++)
00179 ptsom[k] = ptsom[k]/N;
00180
00181 for(n=0; n<N; n++){
00182 ptim2 = tabim2[n].p[0];
00183 for(k=0; k<nbp; k++){
00184
00185 tmpdb = sqrt((double)(ptim2[k]*ptsom[k])) + 0.5;
00186 if( tmpdb < 65536. )
00187 pt0[k] = (pixu2)tmpdb;
00188 else
00189 pt0[k] = 65535;
00190 }
00191
00192 write_imau2_ferm(tabwri+n, im0);
00193 }
00194 }
00195
00196
00197