00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00043 #include "image.h"
00044 #include "proto2D.h"
00045 #include "radar.h"
00046 #include <stdlib.h>
00047 #include <fcntl.h>
00048 #include <math.h>
00049 #include <limits.h>
00050
00051
00052
00053
00054
00055
00068 param * idctexp_lect(idctexp_t *des, param *ptp, char *debq){
00069 char question[500];
00070
00071 sprintf(question, "%s nombre d'images", debq);
00072 lec_param(question, ptp);
00073 des->N = atoi(ptp->rep);
00074 ptp = ptp->next;
00075
00076 sprintf(question, "%s biais a corriger (division apres l'exponentielle)", debq);
00077 lec_param(question, ptp);
00078 des->B = (float)atof(ptp->rep);
00079 ptp = ptp->next;
00080
00081 return(ptp);
00082 }
00083
00084
00098
00099
00100
00101 int idctexp_u2_init(idctexp_t *des, imafl *pt_imdct, imau2 *pt_imres){
00102 int n, k, N;
00103 float c0, ck;
00104 double tmpdb;
00105
00106 N = des->N;
00107
00108 for(n=0; n<N; n++){
00109 if (pt_imres[n].p == NULL){
00110 pt_imres[n].nc = pt_imdct[0].nc;
00111 pt_imres[n].nr = pt_imdct[0].nr;
00112 sprintf(pt_imres[n].nom, "%s_idctexp_%d", pt_imdct[0].nom, n);
00113 alloc_imau2(pt_imres+n);
00114 }
00115 }
00116
00117
00118 if( (des->v0 = (float *)malloc(N*sizeof(float))) == NULL ){
00119 printf ("\n ERREUR idctexp_u2_init : allocation vecteur impossible\n");
00120 exit(1);
00121 }
00122
00123
00124 if( (des->matidct = (float **)malloc(N*sizeof(float *))) == NULL ){
00125 printf ("\n ERREUR idctexp_u2_init : allocation matrice impossible\n");
00126 exit(1);
00127 }
00128 if( (des->matidct[0] = (float *)malloc(N*N*sizeof(float))) == NULL){
00129 printf ("\n ERREUR idctexp_u2_init : allocation image impossible\n");
00130 exit(1);
00131 }
00132 for(n=1; n<N; n++)
00133 des->matidct[n] = des->matidct[0] + n*N;
00134
00135
00136 c0 = (float)sqrt(1./(double)N);
00137 ck = (float)sqrt(2./(double)N);
00138 for(n=0; n<N; n++){
00139 des->matidct[n][0] = c0;
00140 for(k=1; k<N; k++)
00141 des->matidct[n][k] = ck*(float)cos(M_PI*(double)((2*n+1)*k)/(double)(2*N));
00142 }
00143
00144 return(0);
00145 }
00146
00147
00148
00149
00150
00151
00152
00163
00164
00165
00166 int idctexp_u2_calc(idctexp_t *des, imafl *pt_imdct, imau2 *pt_imres){
00167 int i, j, dimX, dimY, n, k, N;
00168 float som, res;
00169
00170 N = des->N;
00171 dimX = pt_imdct->nc;
00172 dimY = pt_imdct->nr;
00173 for(j=0; j<dimY; j++)
00174 for(i=0; i<dimX; i++){
00175 for( k=0; k<N; k++)
00176 des->v0[k] = pt_imdct[k].p[j][i];
00177 for( n=0; n<N; n++){
00178 som = des->matidct[n][0] * des->v0[0];
00179 for( k=1; k<N; k++)
00180 som += des->matidct[n][k] * des->v0[k];
00181 res = (float)exp((double)som) / des->B + 0.5;
00182 if(res >= USHRT_MAX +1)
00183 pt_imres[n].p[j][i] = USHRT_MAX;
00184 else if (res <=0.)
00185 pt_imres[n].p[j][i] = 0;
00186 else
00187 pt_imres[n].p[j][i] = (pixu2)res;
00188 }
00189 }
00190 return(0);
00191 }
00192
00193
00194
00195
00196
00197
00198