lhaar_wavelet.c

Go to the documentation of this file.
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 */
00031 #include "haar_wavelet.h"
00032 #include <stdio.h>
00033 #include <math.h>
00034 #include <stdlib.h>
00035 
00036 
00037 #define MIN3(x,y,z) ( ( ((x)<(y))&&((x)<(z))   )?(x):( ( ((x)>(y))&&((y)<(z))  )?y:z  )  )
00038 
00039 
00050 param* hw_coef_entire_image_lect(hw_coef_entire_image_t* des, param* ptp, char* debq){
00051   char question[500];
00052 
00053   sprintf(question, "%s Scale:", debq); 
00054   lec_param(question, ptp);
00055   des->scale = atoi(ptp->rep);
00056   ptp = ptp->next;
00057   
00058   return(ptp);
00059 }
00060 
00061 
00073 int hw_coef_entire_image_init(hw_coef_entire_image_t* des, ima3Du1* imaIn, ima3Du1* imaOut){
00074 
00075   imaOut->dimx = imaIn->dimx;
00076   imaOut->dimy = imaIn->dimy;
00077   imaOut->dimz = imaIn->dimz;
00078   imaOut->dept = imaIn->dept;
00079   allouer_ima3Du1(imaOut);
00080 
00081 }
00082 
00083 
00084 /* *************************  CALCUL  ***************************/
00094 int hw_coef_entire_image_calc(hw_coef_entire_image_t* des, ima3Du1* imaIn, ima3Du1* imaOut){
00095 
00096   register unsigned int x,y,z,s;
00097   unsigned int  depl_x, depl_y, depl_z;
00098   unsigned int  dim_opt_x, dim_opt_y, dim_opt_z;
00099 
00100   /*calcul des dimensions utilisables de l'image en fonction de la profondeur d'analyse*/
00101   dim_opt_x = imaIn->dimx-(imaIn->dimx%(unsigned int)(pow(2,des->scale)));
00102   dim_opt_y = imaIn->dimy-(imaIn->dimy%(unsigned int)(pow(2,des->scale)));
00103   dim_opt_z = imaIn->dimz-(imaIn->dimz%(unsigned int)(pow(2,des->scale)));
00104 
00105   printf("dim opt x:%d y:%d z:%d\n", dim_opt_x, dim_opt_y, dim_opt_z);
00106 
00107   depl_x = dim_opt_x/2;
00108   depl_y = dim_opt_y/2;
00109   depl_z = dim_opt_z/2;
00110 
00111   /*calcul pour les differentes echelles*/
00112   for( s=0; s<des->scale; s++){
00113     printf("Calcul echelle %d\n", s+1);
00114 
00115     for(z=0; z<dim_opt_z-1; z+=2){
00116       for(y=0; y<dim_opt_y-1; y+=2){
00117         for(x=0; x<dim_opt_x-1; x+=2){
00118         
00119         
00120           imaOut->data[z/2+depl_z][y/2][x/2]=(unsigned char)(128 +(imaIn->data[z][y][x]
00121                                                                    +imaIn->data[z][y][x+1]
00122                                                                    +imaIn->data[z][y+1][x]
00123                                                                    +imaIn->data[z][y+1][x+1]
00124                                                                    -imaIn->data[z+1][y][x]
00125                                                                    -imaIn->data[z+1][y][x+1]
00126                                                                    -imaIn->data[z+1][y+1][x]
00127                                                                    -imaIn->data[z+1][y+1][x+1] )/8);
00128         
00129           imaOut->data[z/2][y/2+depl_y][x/2]=(unsigned char)(128 +( imaIn->data[z][y][x]
00130                                                                +imaIn->data[z][y][x+1]
00131                                                                -imaIn->data[z][y+1][x]
00132                                                                -imaIn->data[z][y+1][x+1]
00133                                                                +imaIn->data[z+1][y][x]
00134                                                                +imaIn->data[z+1][y][x+1]
00135                                                                -imaIn->data[z+1][y+1][x]
00136                                                                -imaIn->data[z+1][y+1][x+1] )/8);
00137         
00138           imaOut->data[z/2+depl_z][y/2+depl_y][x/2]=(unsigned char)(128 +( imaIn->data[z][y][x]
00139                                                                         -imaIn->data[z][y][x+1]
00140                                                                         +imaIn->data[z][y+1][x]
00141                                                                         -imaIn->data[z][y+1][x+1]
00142                                                                         -imaIn->data[z+1][y][x]
00143                                                                         -imaIn->data[z+1][y][x+1]
00144                                                                         +imaIn->data[z+1][y+1][x]
00145                                                                         +imaIn->data[z+1][y+1][x+1] )/8);
00146         
00147           imaOut->data[z/2][y/2][x/2+depl_x]= (unsigned char)(128+
00148                                                               (imaIn->data[z][y][x]
00149                                                                -imaIn->data[z][y][x+1]
00150                                                                +imaIn->data[z][y+1][x]
00151                                                                -imaIn->data[z][y+1][x+1]
00152                                                                +imaIn->data[z+1][y][x]
00153                                                                -imaIn->data[z+1][y][x+1]
00154                                                                +imaIn->data[z+1][y+1][x]
00155                                                                -imaIn->data[z+1][y+1][x+1] )/8);
00156                                                               
00157         
00158           imaOut->data[z/2+depl_z][y/2][x/2+depl_x]=(unsigned char)(128 +( imaIn->data[z][y][x]
00159                                                                         -imaIn->data[z][y][x+1]
00160                                                                         +imaIn->data[z][y+1][x]
00161                                                                         -imaIn->data[z][y+1][x+1]
00162                                                                         -imaIn->data[z+1][y][x]
00163                                                                         -imaIn->data[z+1][y][x+1]
00164                                                                         +imaIn->data[z+1][y+1][x]
00165                                                                         +imaIn->data[z+1][y+1][x+1] )/8);
00166         
00167           imaOut->data[z/2][y/2+depl_y][x/2+depl_x]=(unsigned char)(128 +( imaIn->data[z][y][x]
00168                                                                         -imaIn->data[z][y][x+1]
00169                                                                         -imaIn->data[z][y+1][x]
00170                                                                         +imaIn->data[z][y+1][x+1]
00171                                                                         +imaIn->data[z+1][y][x]
00172                                                                         -imaIn->data[z+1][y][x+1]
00173                                                                         -imaIn->data[z+1][y+1][x]
00174                                                                         +imaIn->data[z+1][y+1][x+1] )/8);
00175         
00176           imaOut->data[z/2+depl_z][y/2+depl_y][x/2+depl_x]=(unsigned char)(128 +( imaIn->data[z][y][x]
00177                                                                                  -imaIn->data[z][y][x+1]
00178                                                                                  -imaIn->data[z][y+1][x]
00179                                                                                  +imaIn->data[z][y+1][x+1]
00180                                                                                  -imaIn->data[z+1][y][x]
00181                                                                                  +imaIn->data[z+1][y][x+1]
00182                                                                                  +imaIn->data[z+1][y+1][x]
00183                                                                                  -imaIn->data[z+1][y+1][x+1] )/8);
00184           if(s==des->scale-1){
00185             imaOut->data[z/2][y/2][x/2]=(unsigned char)(( imaIn->data[z][y][x]
00186                                                          +imaIn->data[z][y][x+1]
00187                                                          +imaIn->data[z][y+1][x]
00188                                                          +imaIn->data[z][y+1][x+1]
00189                                                          +imaIn->data[z+1][y][x]
00190                                                          +imaIn->data[z+1][y][x+1]
00191                                                          +imaIn->data[z+1][y+1][x]
00192                                                          +imaIn->data[z+1][y+1][x+1] )/8);
00193           }else{
00194             imaIn->data[z/2][y/2][x/2]=(unsigned char)(( imaIn->data[z][y][x]
00195                                                          +imaIn->data[z][y][x+1]
00196                                                          +imaIn->data[z][y+1][x]
00197                                                          +imaIn->data[z][y+1][x+1]
00198                                                          +imaIn->data[z+1][y][x]
00199                                                          +imaIn->data[z+1][y][x+1]
00200                                                          +imaIn->data[z+1][y+1][x]
00201                                                          +imaIn->data[z+1][y+1][x+1] )/8);
00202           }         
00203           
00204         
00205         }//fin boucle x
00206       }//fin boucle y
00207     }//fin boucle z
00208   
00209     /*modification des dimensions optimales pour l'echelle suivante*/
00210     dim_opt_x = dim_opt_x/2;
00211     dim_opt_y = dim_opt_y/2;
00212     dim_opt_z = dim_opt_z/2;
00213     /*mise a jour des deplacements*/
00214     depl_x = dim_opt_x/2;
00215     depl_y = dim_opt_y/2;
00216     depl_z = dim_opt_z/2;
00217     
00218   }//fin boucle s
00219 
00220 
00221   /*mettre la valeur 255 dans les voxels de l'image de sortie
00222     que ne peuvent etre trait�du a une taille non multiple de 2^n*/
00223 /*   for(z=dim_min; z<imaIn->dimz-1; z+=2){ */
00224 /*     for(y=dim_min; y<imaIn->dimy-1; y+=2){ */
00225 /*       for(x=dim_min; x<imaIn->dimx-1; x+=2){ */
00226 /*      imaOut->data[z/2][y/2][x/2] = 255; */
00227 /*      imaOut->data[z/2+window/2][y/2][x/2] = 255; */
00228 /*      imaOut->data[z/2][y/2+window/2][x/2] = 255; */
00229 /*      imaOut->data[z/2+window/2][y/2+window/2][x/2] = 255; */
00230 /*      imaOut->data[z/2][y/2][x/2+window/2] = 255; */
00231 /*      imaOut->data[z/2+window/2][y/2][x/2+window/2] = 255; */
00232 /*      imaOut->data[z/2][y/2+window/2][x/2+window/2] = 255; */
00233 /*      imaOut->data[z/2+window/2][y/2+window/2][x/2+window/2] = 255; */
00234   //}//fin boucle x
00235   // }//fin boucle y
00236   //}//fin boucle z
00237 
00238 }//fin fonction calc
00239 
00240 
00241 
00242 
00243 
00244 
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 
00255 
00266 param* hw_coef_on_window_lect(hw_coef_on_window_t* des, param* ptp, char* debq){
00267   char question[500];
00268 
00269   sprintf(question, "%s Scale:", debq); 
00270   lec_param(question, ptp);
00271   des->scale = atoi(ptp->rep);
00272   ptp = ptp->next;
00273   
00274   sprintf(question, "%s Window size X:", debq); 
00275   lec_param(question, ptp);
00276   des->win_x = atoi(ptp->rep);
00277   ptp = ptp->next;
00278   
00279   sprintf(question, "%s Window size Y:", debq); 
00280   lec_param(question, ptp);
00281   des->win_y = atoi(ptp->rep);
00282   ptp = ptp->next;
00283   
00284   sprintf(question, "%s Window size Z:", debq); 
00285   lec_param(question, ptp);
00286   des->win_z = atoi(ptp->rep);
00287   ptp = ptp->next;
00288   
00289   sprintf(question, "%s Direction:", debq); 
00290   lec_param(question, ptp);
00291   des->direction = atoi(ptp->rep);
00292   ptp = ptp->next;
00293   
00294   sprintf(question, "%s Feature:", debq); 
00295   lec_param(question, ptp);
00296   des->feature = atoi(ptp->rep);
00297   ptp = ptp->next;
00298    
00299   return(ptp);
00300 }
00301 
00302 
00303 
00304 
00305 
00306 
00307 
00308 
00319 int hw_coef_on_window_init(hw_coef_on_window_t* des, ima3Du1* imaIn, ima3Du1* imaOut){
00320 
00321   imaOut->lgtete = imaIn->lgtete;
00322   imaOut->dimx = imaIn->dimx;
00323   imaOut->dimy = imaIn->dimy;
00324   imaOut->dimz = imaIn->dimz;
00325   imaOut->dept = imaIn->dept;
00326   allouer_ima3Du1(imaOut);
00327 
00328   /*allocation pour le calcul de la densite d'appartion des intensites*/
00329   des->densite = (float *)calloc( 256, sizeof(float));
00330 
00331   /*calcul des dimensions utilisables de la fenetre d'analyse en fonction de la profondeur d'analyse*/
00332   des->win_opt_x = des->win_x-(des->win_x%(unsigned int)(pow(2,des->scale)));
00333   des->win_opt_y = des->win_y-(des->win_y%(unsigned int)(pow(2,des->scale)));
00334   des->win_opt_z = des->win_z-(des->win_z%(unsigned int)(pow(2,des->scale)));
00335   printf("Dim win optimal: %d %d %d\n", des->win_opt_x, des->win_opt_y, des->win_opt_z);
00336   
00337   des->imaCoef = (ima3Du1* )malloc( sizeof(ima3Du1));
00338   des->imaCoef->dimx = des->win_opt_x;
00339   des->imaCoef->dimy = des->win_opt_y;
00340   des->imaCoef->dimz = des->win_opt_z;
00341   allouer_ima3Du1( des->imaCoef);
00342 
00343   des->imaVal = (ima3Du1* )malloc( sizeof(ima3Du1));
00344   des->imaVal->dimx = des->win_opt_x;
00345   des->imaVal->dimy = des->win_opt_y;
00346   des->imaVal->dimz = des->win_opt_z;
00347   allouer_ima3Du1( des->imaVal);
00348 }
00349 
00350 
00351 
00352 
00360 int hw_coef_on_window_ferm( hw_coef_on_window_t* des){
00361   
00362   free( des->densite);
00363   
00364   liberer_ima3Du1( des->imaCoef);
00365   free( des->imaCoef);
00366   
00367   liberer_ima3Du1( des->imaVal);
00368   free( des->imaVal);
00369 }
00370 
00371 
00372 
00373 
00374 
00375 
00376 /* *************************  CALCUL  ***************************/
00386 int hw_coef_on_window_calc(hw_coef_on_window_t* des, ima3Du1* imaIn, ima3Du1* imaOut){
00387 
00388   register unsigned int x,y,z; /*position relative dans la win d'analyse*/
00389   register unsigned int xo, yo, zo; /*position dans l'image*/
00390   register unsigned int s;
00391   unsigned char  depl_x, depl_y, depl_z;  /*verif utilisation et a virer*/
00392   unsigned char  win_opt_x, win_opt_y, win_opt_z; /*dim optimal de la fenetre d'analyse*/
00393   ima3Du1 * imaVal = des->imaVal;
00394   ima3Du1 * imaCoef = des->imaCoef;
00395   int somme, nb, fac; /*utilisé dans le calcul de l'attribut*/
00396   float entropy, max=0.0;
00397   
00398 
00399   /*Pour tous les pixels traitables de l'images
00400    C'est a dire ceux situe dans une fenetre d'analyse*/
00401   for( zo=0; zo<imaIn->dimz-des->win_opt_z-1; zo+=1){
00402     printf("section %u/%u\n", zo+1, imaIn->dimz);
00403     for( yo=0; yo<imaIn->dimy-des->win_opt_y-1; yo+=1){
00404       for( xo=0; xo<imaIn->dimx-des->win_opt_x-1; xo+=1){
00405           //printf("section %d-%d-%d\n", zo, yo, xo);
00406         
00407         win_opt_x = des->win_opt_x;
00408         win_opt_y = des->win_opt_y;
00409         win_opt_z = des->win_opt_z;
00410   
00411         depl_x = win_opt_x/2;
00412         depl_y = win_opt_y/2;
00413         depl_z = win_opt_z/2;
00414 
00415           /*recopie des valeurs de l'image sur la fenetre dans l'image de travail*/
00416           for(z=0; z<win_opt_z; z++)
00417             for(y=0; y<win_opt_y; y++)
00418               for(x=0; x<win_opt_x; x++){
00419                 des->imaVal->data[z][y][x] = imaIn->data[zo+z][yo+y][xo+x];
00420               }
00421 
00422            /*calcul des coefs pour les differentes echelles*/
00423           for( s=0; s<des->scale; s++){
00424             //printf("Calcul echelle %d\n", s+1);
00425 
00426             /*Parcours de la fenetre d'analyse*/
00427             for(z=0; z<win_opt_z; z+=2){
00428               for(y=0; y<win_opt_y; y+=2){
00429                 for(x=0; x<win_opt_x; x+=2){
00430                   //printf("x=%u/%u, y=%u/%u, z=%u/%u\n", x, win_opt_x, y, win_opt_y, z, win_opt_z);
00431 
00432                   /*Calcul pour toutes les directions possibles*/
00433                   /*Une optilisation possible peut consisté a ne calculer que les coefficients 
00434                     pour une direction donnée*/
00435                   imaCoef->data[z/2+depl_z][y/2][x/2]=(unsigned char)(128 +(imaVal->data[z][y][x]
00436                                                                          +imaVal->data[z][y][x+1]
00437                                                                          +imaVal->data[z][y+1][x]
00438                                                                          +imaVal->data[z][y+1][x+1]
00439                                                                          -imaVal->data[z+1][y][x]
00440                                                                          -imaVal->data[z+1][y][x+1]
00441                                                                          -imaVal->data[z+1][y+1][x]
00442                                                                          -imaVal->data[z+1][y+1][x+1] )/8);
00443 
00444                   imaCoef->data[z/2][y/2+depl_y][x/2]=(unsigned char)(128 +( imaVal->data[z][y][x]
00445                                                                +imaVal->data[z][y][x+1]
00446                                                                -imaVal->data[z][y+1][x]
00447                                                                -imaVal->data[z][y+1][x+1]
00448                                                                +imaVal->data[z+1][y][x]
00449                                                                +imaVal->data[z+1][y][x+1]
00450                                                                -imaVal->data[z+1][y+1][x]
00451                                                                -imaVal->data[z+1][y+1][x+1] )/8);
00452         
00453                   imaCoef->data[z/2+depl_z][y/2+depl_y][x/2]=(unsigned char)(128 +( imaVal->data[z][y][x]
00454                                                                         -imaVal->data[z][y][x+1]
00455                                                                         +imaVal->data[z][y+1][x]
00456                                                                         -imaVal->data[z][y+1][x+1]
00457                                                                         -imaVal->data[z+1][y][x]
00458                                                                         -imaVal->data[z+1][y][x+1]
00459                                                                         +imaVal->data[z+1][y+1][x]
00460                                                                         +imaVal->data[z+1][y+1][x+1] )/8);
00461 
00462      
00463                   imaCoef->data[z/2][y/2][x/2+depl_x]= (unsigned char)(128+
00464                                                               (imaVal->data[z][y][x]
00465                                                                -imaVal->data[z][y][x+1]
00466                                                                +imaVal->data[z][y+1][x]
00467                                                                -imaVal->data[z][y+1][x+1]
00468                                                                +imaVal->data[z+1][y][x]
00469                                                                -imaVal->data[z+1][y][x+1]
00470                                                                +imaVal->data[z+1][y+1][x]
00471                                                                -imaVal->data[z+1][y+1][x+1] )/8);
00472 
00473                   imaCoef->data[z/2+depl_z][y/2][x/2+depl_x]=(unsigned char)(128 +( imaVal->data[z][y][x]
00474                                                                         -imaVal->data[z][y][x+1]
00475                                                                         +imaVal->data[z][y+1][x]
00476                                                                         -imaVal->data[z][y+1][x+1]
00477                                                                         -imaVal->data[z+1][y][x]
00478                                                                         -imaVal->data[z+1][y][x+1]
00479                                                                         +imaVal->data[z+1][y+1][x]
00480                                                                         +imaVal->data[z+1][y+1][x+1] )/8);
00481  
00482                   imaCoef->data[z/2][y/2+depl_y][x/2+depl_x]=(unsigned char)(128 +( imaVal->data[z][y][x]
00483                                                                         -imaVal->data[z][y][x+1]
00484                                                                         -imaVal->data[z][y+1][x]
00485                                                                         +imaVal->data[z][y+1][x+1]
00486                                                                         +imaVal->data[z+1][y][x]
00487                                                                         -imaVal->data[z+1][y][x+1]
00488                                                                         -imaVal->data[z+1][y+1][x]
00489                                                                         +imaVal->data[z+1][y+1][x+1] )/8);
00490 
00491                   imaCoef->data[z/2+depl_z][y/2+depl_y][x/2+depl_x]=(unsigned char)(128 +( imaVal->data[z][y][x]
00492                                                                                  -imaVal->data[z][y][x+1]
00493                                                                                  -imaVal->data[z][y+1][x]
00494                                                                                  +imaVal->data[z][y+1][x+1]
00495                                                                                  -imaVal->data[z+1][y][x]
00496                                                                                  +imaVal->data[z+1][y][x+1]
00497                                                                                  +imaVal->data[z+1][y+1][x]
00498                                                                                  -imaVal->data[z+1][y+1][x+1] )/8);
00499  
00500                   /*Mise a jour des données pour le calcul des échelles suivantes*/
00501                   if(s==des->scale-1){
00502                     imaCoef->data[z/2][y/2][x/2]=(unsigned char)(( imaVal->data[z][y][x]
00503                                                          +imaVal->data[z][y][x+1]
00504                                                          +imaVal->data[z][y+1][x]
00505                                                          +imaVal->data[z][y+1][x+1]
00506                                                          +imaVal->data[z+1][y][x]
00507                                                          +imaVal->data[z+1][y][x+1]
00508                                                          +imaVal->data[z+1][y+1][x]
00509                                                          +imaVal->data[z+1][y+1][x+1] )/8);
00510                   }else{  /*sinon on place directement la valeur moyenne en sortie*/
00511                     imaVal->data[z/2][y/2][x/2]=(unsigned char)(( imaVal->data[z][y][x]
00512                                                          +imaVal->data[z][y][x+1]
00513                                                          +imaVal->data[z][y+1][x]
00514                                                          +imaVal->data[z][y+1][x+1]
00515                                                          +imaVal->data[z+1][y][x]
00516                                                          +imaVal->data[z+1][y][x+1]
00517                                                          +imaVal->data[z+1][y+1][x]
00518                                                          +imaVal->data[z+1][y+1][x+1] )/8);
00519                   }
00520 
00521               }//fin boucle x
00522             }//fin boucle y
00523           }//fin boucle z
00524           
00525           /*modification des dimensions optimales pour l'echelle suivante*/
00526           win_opt_x = win_opt_x/2;
00527           win_opt_y = win_opt_y/2;
00528           win_opt_z = win_opt_z/2;
00529           /*mise a jour des deplacements*/
00530           depl_x = win_opt_x/2;
00531           depl_y = win_opt_y/2;
00532           depl_z = win_opt_z/2;
00533     
00534         }//fin boucle s
00535 
00536         /*calcul de l'attribut*/
00537         /*Idée d'optimisation: voir si le calcul ne peut pas se faire a chaque échelle (dans la boucle s)*/
00538         fac = (int)pow(2,des->scale);
00539         nb = 0;
00540         switch( des->feature){
00541           case 1:
00542             /*Essai de la valeur moyenne sur la composante basse fréquence*/
00543             somme = 0;
00544             for(z=0; z< des->win_opt_z/fac; z++)
00545               for(y=0; y<des->win_opt_y/fac; y++)
00546                 for(x=0; x<des->win_opt_x/fac; x++){
00547                   somme +=  imaVal->data[z][y][x];
00548                   nb++;
00549                 }
00550             imaOut->data[zo+des->win_opt_z/2][yo+des->win_opt_y/2][xo+des->win_opt_x/2]= somme/nb;
00551             break;
00552           case 2:
00553             /*Entropy sur la distribution dans le premier cadran*/
00554             entropy = 0.0;
00555             for( s=0; s<256; s++) des->densite[s]=0.0; /*initialisation de la distribution*/
00556             for(z=0; z< des->win_opt_z/fac; z++)
00557               for(y=0; y<des->win_opt_y/fac; y++)
00558                 for(x=0; x<des->win_opt_x/fac; x++){
00559                   des->densite[ imaVal->data[z][y][x] ] += 1.0;
00560                   nb++;
00561                 }
00562             for( s=0; s<256; s++) des->densite[s]= des->densite[s]/nb; /*normalisation*/
00563             for( s=0; s<256; s++) {
00564               if (des->densite[s]!=0.0) entropy = entropy - des->densite[s]*log10f( des->densite[s]);
00565               if( entropy>max) max = entropy;
00566               //printf("test %f -- %f\n", des->densite[s], des->densite[s]*log10f( des->densite[s]));
00567             }
00568             //printf("Max entropy: %f sur %f\n", max, log10f(256));
00569             imaOut->data[zo+des->win_opt_z/2][yo+des->win_opt_y/2][xo+des->win_opt_x/2]= (unsigned char)( entropy/log10(256)*255.0);
00570             break;
00571           default:
00572             imaOut->data[zo+des->win_opt_z/2][yo+des->win_opt_y/2][xo+des->win_opt_x/2]= 255;
00573         }
00574 
00575         /*sauvegarde du resultat dans le voxel central de la fenetre d'analyse sachant que les
00576         position dans la fenetre d'analyse sont toutes exprimées par rapport au coin supérieur gauche
00577         (1er coin par rapport a l'origine)*/
00578         //imaOut->data[zo+des->win_opt_z/2][yo+des->win_opt_y/2][xo+des->win_opt_x/2]= somme/nb;
00579 
00580       }//fin boucle sur xo
00581     }//fin boucle sur yo
00582   }//fin boucle sur zo
00583 
00584 
00585 }//fin fonction calc

Generated on Tue Apr 22 13:31:06 2008 for volume by  doxygen 1.5.3