00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00041 #include "image.h"
00042 #include "proto2D.h"
00043 #include "radar.h"
00044 #include <stdlib.h>
00045 #include <fcntl.h>
00046 #include <math.h>
00047 #include <limits.h>
00048
00049
00050
00051
00052
00053
00066 param * logdct_lect(logdct_t *des, param *ptp, char *debq){
00067 char question[500];
00068
00069 sprintf(question, "%s nombre d'images", debq);
00070 lec_param(question, ptp);
00071 des->N = atoi(ptp->rep);
00072 ptp = ptp->next;
00073
00074 return(ptp);
00075 }
00076
00077
00089
00090
00091
00092 int logdct_u2_init(logdct_t *des, imau2 *pt_im0, imafl *pt_imres){
00093 int n, k, N;
00094 float ck;
00095 double tmpdb;
00096
00097 N = des->N;
00098
00099 for(n=0; n<N; n++){
00100 pt_imres[n].nc = pt_im0[0].nc;
00101 pt_imres[n].nr = pt_im0[0].nr;
00102 sprintf(pt_imres[n].nom, "%s_logdct_%d", pt_im0[0].nom, n);
00103 alloc_imafl(pt_imres+n);
00104 }
00105
00106
00107 if( (des->v0 = (float *)malloc(N*sizeof(float))) == NULL ){
00108 printf ("\n ERREUR logdct_u2_init : allocation vecteur impossible\n");
00109 exit(1);
00110 }
00111
00112
00113 if( (des->matdct = (float **)malloc(N*sizeof(float *))) == NULL ){
00114 printf ("\n ERREUR logdct_u2_init : allocation matrice impossible\n");
00115 exit(1);
00116 }
00117 if( (des->matdct[0] = (float *)malloc(N*N*sizeof(float))) == NULL){
00118 printf ("\n ERREUR logdct_u2_init : allocation image impossible\n");
00119 exit(1);
00120 }
00121 for(k=1; k<N; k++)
00122 des->matdct[k] = des->matdct[0] + k*N;
00123
00124
00125 ck = (float)sqrt(1./(double)N);
00126 for(n=0; n<N; n++){
00127 des->matdct[0][n] = ck;
00128 }
00129 ck = (float)sqrt(2./(double)N);
00130 for(k=1; k<N; k++)
00131 for(n=0; n<N; n++)
00132 des->matdct[k][n] = ck*(float)cos(M_PI*(double)((2*n+1)*k)/(double)(2*N));
00133
00134
00135 des->tablog[0] = 0. ;
00136 for(n=1; n<65536; n++)
00137 des->tablog[n] = (float)log((double)n);
00138
00139 return(0);
00140 }
00141
00142
00143
00144
00145
00146
00147
00158
00159
00160
00161 int logdct_u2_calc(logdct_t *des, imau2 *pt_im0, imafl *pt_imres){
00162 int i, j, dimX, dimY, n, k, N;
00163 float som;
00164
00165 N = des->N;
00166 dimX = pt_im0->nc;
00167 dimY = pt_im0->nr;
00168 for(j=0; j<dimY; j++)
00169 for(i=0; i<dimX; i++){
00170 for( n=0; n<N; n++)
00171 des->v0[n] = des->tablog[pt_im0[n].p[j][i]];
00172 for( k=0; k<N; k++){
00173 som = des->matdct[k][0] * des->v0[0];
00174 for( n=1; n<N; n++)
00175 som += des->matdct[k][n] * des->v0[n];
00176 pt_imres[k].p[j][i] = som;
00177 }
00178 }
00179 return(0);
00180 }
00181
00182
00183
00184
00185
00186
00187
00188