volume.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 */
00019 #include <stdlib.h>
00020 #include <stdio.h>
00021 #include <rasterfile.h>
00022 #include <stdarg.h>
00023 #include "volume.h"
00024 
00025 #ifdef INVERSE_DATA
00026   #include "permut.h"
00027 #endif
00028 
00029 
00042 void lire_longueur_trace( FILE * fin, int *long_trace)
00043 {   
00044   fseek( fin, DECAL_LGTRACE, SEEK_SET);
00045   fread(long_trace,sizeof(int),1,fin);
00046   
00047 #ifdef INVERSE_DATA
00048   permuteInt((char *)long_trace);
00049 #endif
00050 }
00051 
00052 
00068 void ecr_longueur_trace( FILE * fout,  int long_trace)
00069 {  
00070  
00071 #ifdef INVERSE_DATA
00072   permuteInt((char *)&long_trace);
00073 #endif
00074 
00075     fseek(fout,DECAL_LGTRACE,SEEK_SET);
00076     fwrite(&long_trace, sizeof(int),1,fout);
00077 }
00078 
00079 
00093 void lire_nb_trace(FILE * fin, int * nb_trace)
00094 {   
00095   fseek(fin, DECAL_NBTRACE, SEEK_SET);
00096   fread(nb_trace, sizeof(int),1,fin);
00097 
00098 #ifdef INVERSE_DATA
00099   permuteInt((char *)nb_trace);
00100 #endif
00101 }
00102 
00103 
00104 
00119 void ecr_nb_trace(FILE * fout, int nb_trace)
00120 {   
00121  
00122 #ifdef INVERSE_DATA
00123   permuteInt((char *)&nb_trace);
00124 #endif
00125 
00126     fseek(fout,DECAL_NBTRACE,SEEK_SET);
00127     fwrite(&nb_trace, sizeof(int) ,1,fout);
00128 }
00129 
00130 
00143 void lire_nb_plan( FILE * fin,int * nb_plan)
00144 {
00145     fseek(fin,DECAL_NBPLAN,SEEK_SET);
00146     fread(nb_plan, sizeof(int),1,fin);
00147 #ifdef INVERSE_DATA
00148   permuteInt((char *)nb_plan);
00149 #endif
00150 }
00151 
00152 
00167 void ecr_nb_plan( FILE * fout, int nb_plan)
00168 {
00169  
00170 #ifdef INVERSE_DATA
00171   permuteInt((char *)&nb_plan);
00172 #endif
00173 
00174     fseek(fout,DECAL_NBPLAN,SEEK_SET);
00175     fwrite(&nb_plan, sizeof(int),1,fout);
00176 }
00177 
00178 
00191 void lire_nb_octet(FILE * fin, int * nb_octet)
00192 {
00193     fseek(fin,DECAL_NBOCTET,SEEK_SET);
00194     fread(nb_octet, sizeof(int),1,fin);
00195 
00196 #ifdef INVERSE_DATA
00197   permuteInt((char *)nb_octet);
00198 #endif
00199 }
00200 
00201 
00217 void ecr_nb_octet( FILE * fout, int  nb_octet)
00218 {
00219  
00220 #ifdef INVERSE_DATA
00221   permuteInt((char *)&nb_octet);
00222 #endif
00223 
00224     fseek(fout,DECAL_NBOCTET,SEEK_SET);
00225     fwrite(&nb_octet, sizeof(int),1,fout);
00226 }
00227 
00228 
00240 void lire_longueur_entete( FILE * fin, int *long_entete)
00241 {   
00242     fseek(fin,DECAL_LGTETE,SEEK_SET);
00243     fread(long_entete, sizeof(int), 1, fin);   
00244 
00245 #ifdef INVERSE_DATA
00246   permuteInt((char *)long_entete);
00247 #endif
00248 }
00249 
00250 
00251 
00263 void ecr_longueur_entete( FILE * fout, int long_entete)
00264 {   
00265  
00266 #ifdef INVERSE_DATA
00267   permuteInt((char *)&long_entete);
00268 #endif
00269 
00270     fseek(fout,DECAL_LGTETE,SEEK_SET);
00271     fwrite(&long_entete, sizeof(int), 1, fout);   
00272 }
00273 
00274 
00275 
00289 void copie_entete( FILE *fin,
00290                    FILE *fout,
00291                    int nb_plan,
00292                    int nb_octet)
00293 {
00294     int lgtete;
00295     char *data;
00296 
00297     lire_longueur_entete(fin,&lgtete);
00298 
00299     fseek(fin,0,SEEK_SET);
00300     fseek(fout,0,SEEK_SET);
00301 
00302     data=(char *)malloc(lgtete*sizeof(char));
00303 
00304     fread(data, lgtete*sizeof(char), 1, fin);
00305     fwrite(data, lgtete*sizeof(char), 1, fout);
00306 
00307     if(nb_plan!=0){
00308       /* fseek(fout, DECAL_NBPLAN,SEEK_SET); */
00309       /* fwrite(&nb_plan, sizeof(int), 1, fout); */
00310       ecr_nb_plan(fout,nb_plan);
00311     }
00312 
00313     if(nb_octet!=0){
00314       /* fseek(fout, DECAL_NBOCTET, SEEK_SET); */
00315       /* fwrite(&nb_octet, sizeof(int), 1, fout); */
00316       ecr_nb_octet(fout,nb_octet);
00317     }
00318 
00319     fseek(fout, lgtete, SEEK_SET);
00320     free(data);    
00321 }
00322 
00348 FILE *lect_ima3Ds2(char * nomfich, ima3Ds2 * image, int type, ...)    
00349 {
00350     int entete, nb_octet;
00351     FILE * fin;
00352     int i,j,k;
00353     unsigned char tmp;
00354     va_list ap;
00355     int pile[2];
00356  
00357     fin = fopen(nomfich,"rw");
00358     if(fin==NULL) 
00359         {
00360             printf("Can't open file %s\n",nomfich);
00361             exit(1);
00362         }   
00363   
00364     lire_longueur_trace(fin, &image->dimx);
00365     lire_nb_trace(fin, &image->dimy);
00366     lire_longueur_entete(fin, &image->lgtete);
00367     image->dept=16;
00368     lire_nb_octet(fin, &nb_octet);
00369 
00370     switch(type){
00371     case ALL:
00372         {
00373             lire_nb_plan(fin,&(image->dimz));
00374             fseek(fin, image->lgtete, SEEK_SET);
00375             break;
00376         }
00377     case ONE:
00378         {
00379             image->dimz=1;
00380             va_start( ap, type);
00381             pile[0]=va_arg(ap, int);
00382             fseek(fin, image->lgtete + (pile[0]-1)*(image->dimy)*(image->dimx)*(nb_octet/8), SEEK_SET);
00383             va_end(ap);
00384             break;
00385         }
00386     case MANY:
00387         {
00388             va_start( ap, type);
00389             pile[0]=va_arg(ap, int);
00390             pile[1]=va_arg(ap, int);
00391             va_end(ap);
00392             image->dimz=pile[1]-pile[0]+1;
00393             fseek(fin, image->lgtete + (pile[0]-1)*(image->dimy)*(image->dimx)*(nb_octet/8), SEEK_SET);
00394             break;
00395         }
00396     }
00397 
00398     image->data = (short ***)malloc(image->dimz * sizeof(short **));   
00399     for(i=0; i<image->dimz; i++)
00400         {
00401             image->data[i] = (short **)malloc(image->dimy * sizeof(short *));
00402             for(j=0; j<image->dimy; j++)
00403                 {
00404                     image->data[i][j] = (short *)malloc(image->dimx * sizeof(short));
00405                 }
00406         }
00407 
00408     if(nb_octet==16)
00409         {
00410           for(i=0; i<(image->dimz); i++)
00411             for(j=0; j<(image->dimy); j++)
00412               for(k=0; k<(image->dimx); k++){
00413                 fread(&(image->data[i][j][k]), sizeof(short), 1, fin);
00414 #ifdef INVERSE_DATA
00415                 permuteShort( (char *)&image->data[i][j][k] );
00416 #endif
00417               }
00418         }
00419     else
00420         {
00421             for(i=0; i<(image->dimz); i++)
00422                 for(j=0; j<(image->dimy); j++)
00423                     for(k=0; k<(image->dimx); k++)
00424                         {
00425                         fread(&tmp, sizeof(unsigned char), 1, fin);
00426                         image->data[i][j][k]=(short)tmp;
00427 #ifdef INVERSE_DATA
00428                         permuteShort( (char *)&image->data[i][j][k] );
00429 #endif
00430                         }
00431         }
00432 
00433     return(fin);
00434     fclose(fin);
00435     
00436 }
00437 
00462 FILE *lect_ima3Du1(char * nomfich, ima3Du1 * image, int type, ...)    
00463 {
00464     int entete, nb_octet, deplacement;
00465     FILE * fin;
00466     int x,y,z;
00467     short tmp, maxi, mini;
00468     va_list ap;
00469     int pile[2];
00470     
00471     fin = fopen(nomfich,"rw");
00472     if(fin==NULL) 
00473         {
00474             printf("Can't open file %s\n",nomfich);
00475             exit(1);
00476         }  
00477     lire_longueur_entete(fin,&(image->lgtete));
00478     lire_longueur_trace(fin,&(image->dimx));
00479     lire_nb_trace(fin,&(image->dimy));
00480     lire_nb_octet(fin, &nb_octet);
00481  
00482 
00483     switch(type){
00484     case ALL:
00485         {
00486             lire_nb_plan(fin,&(image->dimz));
00487             deplacement=image->lgtete;
00488             break;
00489         }
00490     case ONE:
00491         {
00492             image->dimz=1;
00493             va_start( ap, type);
00494             pile[0]=va_arg(ap, int);
00495             deplacement = image->lgtete + (pile[0]-1)*(image->dimy)*(image->dimx)*(nb_octet/8);
00496             va_end(ap);
00497             break;
00498         }
00499     case MANY:
00500         {
00501             va_start( ap, type);
00502             pile[0]=va_arg(ap, int);
00503             pile[1]=va_arg(ap, int);
00504             va_end(ap);
00505             image->dimz=pile[1]-pile[0]+1;
00506             deplacement = image->lgtete + (pile[0]-1)*(image->dimy)*(image->dimx)*(nb_octet/8);
00507             fseek(fin, deplacement, SEEK_SET);
00508             break;
00509         }
00510    }
00511 
00512    image->dept=8;
00513 
00514    image->data = (unsigned char ***)malloc(image->dimz * sizeof(unsigned char **));
00515    for(z=0; z<image->dimz; z++)
00516        {
00517            image->data[z] = (unsigned char **)malloc(image->dimy * sizeof(unsigned char *));
00518            for(y=0; y<image->dimy; y++)
00519                {
00520                    image->data[z][y] = (unsigned char *)malloc(image->dimx * sizeof(unsigned char));
00521                }
00522        }
00523           
00524    fseek(fin, deplacement, SEEK_SET);
00525    
00526    if(nb_octet==8)
00527        {
00528            for(z=0; z<(image->dimz); z++)
00529                for(y=0; y<(image->dimy); y++)
00530                    for(x=0; x<(image->dimx); x++)
00531                        fread(&(image->data[z][y][x]), sizeof(unsigned char), 1, fin);
00532        }
00533    else
00534        {
00535            maxi = 0;
00536            mini = 0;
00537            fseek(fin, deplacement, SEEK_SET);
00538            for(z=0; z<(image->dimz); z++)
00539                for(y=0; y<(image->dimy); y++)
00540                    for(x=0; x<(image->dimx); x++)
00541                        {
00542                            fread(&tmp, sizeof(short), 1, fin);
00543 #ifdef INVERSE_DATA
00544                            permuteShort((char *)&tmp);
00545 #endif
00546                            if(tmp>maxi) maxi=tmp;
00547                            if(tmp<mini) mini=tmp;
00548                        }
00549            printf("max=%d; min=%d\n",maxi, mini);
00550            fseek(fin, deplacement, SEEK_SET);
00551               
00552            for(z=0; z<(image->dimz); z++)
00553                for(y=0; y<(image->dimy); y++)
00554                    for(x=0; x<(image->dimx); x++)
00555                        {
00556                            fread(&tmp, sizeof(short), 1, fin);
00557 #ifdef INVERSE_DATA
00558                            permuteShort((char *)&tmp);
00559 #endif
00560                            /*tmp=(short)((((double)(tmp)/(double)(maxi-mini))*255.0)+127);*/
00561                            if(maxi<-mini) maxi = -mini;
00562                            tmp = (short)( (((double)tmp / (double)(maxi)) *127 )+127 );
00563                            image->data[z][y][x]=(unsigned char)(tmp);
00564                        }
00565        }
00566    //fclose(fin);
00567    return(fin);
00568     
00569 }
00570 
00571 
00589 FILE *lect_ima3Dd(char * nomfich, ima3Dd * image, int type, ...)
00590 {
00591     int entete, nb_octet;
00592     FILE * fin;
00593     int i,j,k;
00594     unsigned char tmp;
00595     va_list ap;
00596     int pile[2];
00597  
00598     fin = fopen(nomfich,"rw");
00599     if(fin==NULL) 
00600         {
00601             printf("Can't open file %s\n",nomfich);
00602             exit(1);
00603         }   
00604   
00605     lire_longueur_trace(fin, &image->dimx);
00606     lire_nb_trace(fin, &image->dimy);
00607     lire_longueur_entete(fin, &image->lgtete);
00608     image->dept=64;
00609     lire_nb_octet(fin, &nb_octet);
00610 
00611     switch(type){
00612     case ALL:
00613         {
00614             lire_nb_plan(fin,&(image->dimz));
00615             fseek(fin, image->lgtete, SEEK_SET);
00616             break;
00617         }
00618     case ONE:
00619         {
00620             image->dimz=1;
00621             va_start( ap, type);
00622             pile[0]=va_arg(ap, int);
00623             fseek(fin, image->lgtete + (pile[0]-1)*(image->dimy)*(image->dimx)*(nb_octet/8), SEEK_SET);
00624             va_end(ap);
00625             break;
00626         }
00627     case MANY:
00628         {
00629             va_start( ap, type);
00630             pile[0]=va_arg(ap, int);
00631             pile[1]=va_arg(ap, int);
00632             va_end(ap);
00633             image->dimz=pile[1]-pile[0]+1;
00634             fseek(fin, image->lgtete + (pile[0]-1)*(image->dimy)*(image->dimx)*(nb_octet/8), SEEK_SET);
00635             break;
00636         }
00637     }
00638 
00639     image->data = (double ***)malloc(image->dimz * sizeof(double **));
00640     for(i=0; i<image->dimz; i++)
00641         {
00642             image->data[i] = (double **)malloc(image->dimy * sizeof(double *));
00643             for(j=0; j<image->dimy; j++)
00644                 {
00645                     image->data[i][j] = (double *)malloc(image->dimx * sizeof(double));
00646                 }
00647         }
00648 
00649     if(nb_octet==64)
00650         {
00651           for(i=0; i<(image->dimz); i++)
00652             for(j=0; j<(image->dimy); j++)
00653               for(k=0; k<(image->dimx); k++){
00654                 fread(&(image->data[i][j][k]), sizeof(double), 1, fin);
00655 #ifndef INVERSE_DATA
00656             #error "Only implemented for little-endian, not implemented for big-endian!"
00657 #endif
00658               }
00659         }
00660     else
00661         {
00662             printf("Image %s is not double encoded..\n",nomfich);
00663             exit(1);
00664         }   
00665 
00666     return(fin);
00667     fclose(fin);
00668     
00669 }
00670 
00683 void ecr_ima3Du1( char * nomfich, ima3Du1 *image)    
00684 {
00685     FILE * fin;
00686     int x,y,z;
00687     char caract='a';
00688     int i;
00689     
00690     /*reservation d'un entete de 80 octets*/
00691     fin = fopen(nomfich,"wb");
00692     for (i = 0; i < 80; i++)
00693         fwrite(&caract,sizeof(char), 1, fin);
00694 
00695     /*ecriture de la longueur d'une trace*/
00696     /* fseek(fin,DECAL_LGTRACE,SEEK_SET); */
00697     /* fwrite(&image->dimx,sizeof(int),1,fin); */
00698     ecr_longueur_trace( fin, image->dimx);
00699 
00700     /*ecriture du nombre de trace*/
00701     /* fseek(fin,DECAL_NBTRACE,SEEK_SET); */
00702     /* fwrite(&image->dimy,sizeof(int),1,fin); */
00703     ecr_nb_trace( fin, image->dimy);
00704 
00705     /*ecriture du nombre de plan*/
00706     /* fseek(fin,DECAL_NBPLAN,SEEK_SET); */
00707     /* fwrite(&image->dimz,sizeof(int),1,fin); */
00708     ecr_nb_plan( fin, image->dimz);
00709 
00710     /*ecriture du nombre d'octet*/
00711     x=8;
00712     /* fseek(fin,DECAL_NBOCTET,SEEK_SET); */
00713     /* fwrite(&x,sizeof(int),1,fin); */
00714     ecr_nb_octet( fin, x);
00715 
00716     /*ecriture de la longueur de l'entete*/
00717     x=80;
00718     /* fseek(fin,DECAL_LGTETE,SEEK_SET); */
00719     /* fwrite(&x, sizeof(int), 1, fin); */
00720     ecr_longueur_entete(fin, x);
00721     
00722     /*ecriture de l'image*/
00723     fseek(fin, 80, SEEK_SET);
00724     for(z=0; z<(image->dimz); z++)
00725       for(y=0; y<(image->dimy); y++)
00726         for(x=0; x<(image->dimx); x++)    
00727                 fwrite(&image->data[z][y][x],sizeof(unsigned char),1,fin);
00728     fclose(fin);
00729     
00730 }
00731 
00732 
00745 void ecr_ima3Ds2(char * nomfich, ima3Ds2 *image)    
00746 {
00747     FILE * fin;
00748     int x,y,z;
00749     char caract='a';
00750     int i;
00751      
00752     /*reservation d'un entete de 80 octets*/
00753     fin = fopen(nomfich,"wb");
00754     for (i = 0; i < 80; i++)
00755         fwrite(&caract,sizeof(char), 1, fin);
00756 
00757     /*ecriture de la longueur d'une trace*/
00758     /* fseek(fin,DECAL_LGTRACE,SEEK_SET); */
00759     /* fwrite(&image->dimx,sizeof(int),1,fin); */
00760     ecr_longueur_trace( fin, image->dimx);
00761 
00762     /*ecriture du nombre de trace*/
00763     /* fseek(fin,DECAL_NBTRACE,SEEK_SET); */
00764     /* fwrite(&image->dimy,sizeof(int),1,fin); */
00765     ecr_nb_trace( fin, image->dimy);
00766 
00767     /*ecriture du nombre de plan*/
00768     /* fseek(fin,DECAL_NBPLAN,SEEK_SET); */
00769     /* fwrite(&image->dimz,sizeof(int),1,fin); */
00770     ecr_nb_plan( fin, image->dimz);
00771 
00772     /*ecriture du nombre d'octet*/
00773     x=16;
00774     /* fseek(fin,DECAL_NBOCTET,SEEK_SET); */
00775     /* fwrite(&x,sizeof(int),1,fin); */
00776     ecr_nb_octet( fin, x);
00777 
00778     /*ecriture de la longueur de l'entete*/
00779     x=80;
00780     /* fseek(fin,DECAL_LGTETE,SEEK_SET); */
00781     /* fwrite(&x, sizeof(int), 1, fin); */
00782     ecr_longueur_entete(fin, x);
00783 
00784     /*ecriture de l'image*/
00785     fseek(fin, 80, SEEK_SET);
00786     for(z=0; z<(image->dimz); z++)
00787         for(y=0; y<(image->dimy); y++)
00788           for(x=0; x<(image->dimx); x++){
00789 #ifdef INVERSE_DATA
00790             permuteShort((char *)&image->data[z][y][x]);
00791 #endif
00792             fwrite(&image->data[z][y][x],sizeof(short),1,fin);
00793           }
00794     fclose(fin);
00795     
00796 }
00797 
00810 void ecr_ima3Dd(char * nomfich, ima3Dd *image)
00811 {
00812                 FILE * fin;
00813     int x,y,z;
00814     char caract='a';
00815     int i;
00816      
00817     /*reservation d'un entete de 80 octets*/
00818     fin = fopen(nomfich,"wb");
00819     for (i = 0; i < 80; i++)
00820         fwrite(&caract,sizeof(char), 1, fin);
00821 
00822     /*ecriture de la longueur d'une trace*/
00823     /* fseek(fin,DECAL_LGTRACE,SEEK_SET); */
00824     /* fwrite(&image->dimx,sizeof(int),1,fin); */
00825     ecr_longueur_trace( fin, image->dimx);
00826 
00827     /*ecriture du nombre de trace*/
00828     /* fseek(fin,DECAL_NBTRACE,SEEK_SET); */
00829     /* fwrite(&image->dimy,sizeof(int),1,fin); */
00830     ecr_nb_trace( fin, image->dimy);
00831 
00832     /*ecriture du nombre de plan*/
00833     /* fseek(fin,DECAL_NBPLAN,SEEK_SET); */
00834     /* fwrite(&image->dimz,sizeof(int),1,fin); */
00835     ecr_nb_plan( fin, image->dimz);
00836 
00837     /*ecriture du nombre d'octet*/
00838     x=64;
00839     /* fseek(fin,DECAL_NBOCTET,SEEK_SET); */
00840     /* fwrite(&x,sizeof(int),1,fin); */
00841     ecr_nb_octet( fin, x);
00842 
00843     /*ecriture de la longueur de l'entete*/
00844     x=80;
00845     /* fseek(fin,DECAL_LGTETE,SEEK_SET); */
00846     /* fwrite(&x, sizeof(int), 1, fin); */
00847     ecr_longueur_entete(fin, x);
00848 
00849     /*ecriture de l'image*/
00850     fseek(fin, 80, SEEK_SET);
00851     for(z=0; z<(image->dimz); z++)
00852         for(y=0; y<(image->dimy); y++)
00853           for(x=0; x<(image->dimx); x++){
00854 #ifndef INVERSE_DATA
00855             #error "Only implemented for little-endian, not implemented for big-endian!"
00856 #endif
00857             fwrite(&image->data[z][y][x],sizeof(double),1,fin);
00858           }
00859     fclose(fin);
00860     
00861 }
00862 
00863 
00864 
00875 void liberer_ima3Ds2( ima3Ds2 * image)
00876 {
00877     short i,j;
00878     for(i=0; i<(image->dimz); i++)
00879         for(j=0; j<(image->dimy); j++)
00880             free(image->data[i][j]);
00881 
00882     free(image->data);    
00883 }
00884 
00885 
00896 void liberer_ima3Du1( ima3Du1 * image)
00897 {
00898     short i,j;
00899     for(i=0; i<(image->dimz); i++)
00900         for(j=0; j<(image->dimy); j++)
00901             free(image->data[i][j]);
00902 
00903     free(image->data);    
00904 }
00905 
00906 
00917 void liberer_ima3Du4( ima3Du4 * image)
00918 {
00919     short i,j;
00920     for(i=0; i<(image->dimz); i++)
00921         for(j=0; j<(image->dimy); j++)
00922             free(image->data[i][j]);
00923 
00924     free(image->data);    
00925 }
00926 
00927 
00938 void liberer_ima3Du8( ima3Du8 * image)
00939 {
00940     short i,j;
00941     for(i=0; i<(image->dimz); i++)
00942         for(j=0; j<(image->dimy); j++)
00943             free(image->data[i][j]);
00944 
00945     free(image->data);    
00946 }
00947 
00958 void liberer_ima3Dd(ima3Dd * image)
00959 {
00960     short i,j;
00961     for(i=0; i<(image->dimz); i++)
00962         for(j=0; j<(image->dimy); j++)
00963             free(image->data[i][j]);
00964 
00965     free(image->data);    
00966 }
00967 
00977 void liberer_ima3Du1_sequence(ima3Du1 * ima)
00978 {
00979     short i,j;
00980     for(i=0; i<(ima->sequence_width); i++)
00981         for(j=0; j<(ima->dimy); j++)
00982             free(ima->data[i][j]);
00983 
00984     free(ima->data);    
00985 }
00986 
00987 
00988 
00998 void allouer_ima3Du1_sequence(ima3Du1  * ima)
00999 {
01000   int z,y;
01001 
01002     ima->data = (unsigned char ***)calloc(ima->sequence_width, sizeof(unsigned char **));
01003     for(z=0; z<ima->sequence_width; z++)
01004        {
01005            ima->data[z] = (unsigned char **)calloc(ima->dimy, sizeof(unsigned char *));
01006            for(y=0; y<ima->dimy; y++)
01007                {
01008                    ima->data[z][y] = (unsigned char *)calloc(ima->dimx, sizeof(unsigned char));
01009                }
01010        }
01011 
01012 }
01013 
01014 
01025 void allouer_ima3Du1(ima3Du1  * ImaOut)
01026 {
01027     int y, z;
01028 
01029     ImaOut->data = (unsigned char ***)calloc(ImaOut->dimz, sizeof(unsigned char **));
01030     for(z=0; z<ImaOut->dimz; z++)
01031        {
01032            ImaOut->data[z] = (unsigned char **)calloc(ImaOut->dimy, sizeof(unsigned char *));
01033            for(y=0; y<ImaOut->dimy; y++)
01034                {
01035                    ImaOut->data[z][y] = (unsigned char *)calloc(ImaOut->dimx, sizeof(unsigned char));
01036                }
01037        }
01038 
01039 }
01040 
01041 
01042 
01053 void allouer_ima3Du4(ima3Du4  * ImaOut)
01054 {
01055     int y, z;
01056 
01057     ImaOut->data = (unsigned int ***)calloc(ImaOut->dimz, sizeof(unsigned int **));
01058     for(z=0; z<ImaOut->dimz; z++)
01059        {
01060            ImaOut->data[z] = (unsigned  int **)calloc(ImaOut->dimy, sizeof(unsigned  int *));
01061            for(y=0; y<ImaOut->dimy; y++)
01062                {
01063                    ImaOut->data[z][y] = (unsigned int *)calloc(ImaOut->dimx, sizeof(unsigned int));
01064                }
01065        }
01066 
01067 }
01068 
01069 
01070 
01071 
01082 void allouer_ima3Du8(ima3Du8  * ImaOut)
01083 {
01084     int y, z;
01085 
01086     ImaOut->data = (unsigned long int ***)calloc(ImaOut->dimz, sizeof(unsigned long int **));
01087     for(z=0; z<ImaOut->dimz; z++)
01088        {
01089            ImaOut->data[z] = (unsigned long int **)calloc(ImaOut->dimy, sizeof(unsigned long int *));
01090            for(y=0; y<ImaOut->dimy; y++)
01091                {
01092                    ImaOut->data[z][y] = (unsigned long int *)calloc(ImaOut->dimx, sizeof(unsigned long int));
01093                }
01094        }
01095 
01096 }
01097 
01098 
01099 
01100 
01101 
01102 
01114 void allouer_ima3Ds2(ima3Ds2 * ImaOut)
01115 {
01116     int y, z;
01117 
01118     ImaOut->data = (short ***)calloc(ImaOut->dimz, sizeof(short **));   
01119     for(z=0; z<ImaOut->dimz; z++)
01120         {
01121             ImaOut->data[z] = (short **)calloc(ImaOut->dimy, sizeof(short *));
01122             for(y=0; y<ImaOut->dimy; y++)
01123                 {
01124                     ImaOut->data[z][y] = (short *)calloc(ImaOut->dimx,  sizeof(short));
01125                 }
01126         }
01127 
01128 
01129 }
01130 
01142 void allouer_ima3Dd(ima3Dd * ImaOut)
01143 {
01144     int y, z;
01145 
01146     ImaOut->data = (double ***)calloc(ImaOut->dimz, sizeof(double **));
01147     for(z=0; z<ImaOut->dimz; z++)
01148         {
01149             ImaOut->data[z] = (double **)calloc(ImaOut->dimy, sizeof(double *));
01150             for(y=0; y<ImaOut->dimy; y++)
01151                 {
01152                     ImaOut->data[z][y] = (double *)calloc(ImaOut->dimx,  sizeof(double));
01153                 }
01154         }
01155 
01156 
01157 }
01158 
01159 
01160 
01161 
01162 
01163 /*
01164 void allouer_ima3Ds2(ima3Ds2 * ImaIn)
01165 {
01166     int y, z;
01167   if( (ImaIn->data = (short ***)calloc(ImaIn->dimz, sizeof(short ***))) == NULL )
01168         {printf ("\n allocation image impossible\n");  exit(1);}
01169 
01170   for(z=0; z<ImaIn->dimz; z++)
01171       {
01172           if( (ImaIn->data[z] = (short **)calloc(ImaIn->dimy, sizeof(short **))) == NULL )
01173               {printf ("\n allocation image impossible\n");  exit(1);}
01174       }
01175   if( (ImaIn->data[0][0] = (short *)calloc(ImaIn->dimz*ImaIn->dimy*ImaIn->dimx, sizeof(short *))) == NULL)
01176       {printf ("\n allocation image impossible\n");  exit(1); }
01177 
01178   for(z=0; z<ImaIn->dimz; z++)
01179       for(y=0; y<ImaIn->dimz; y++)
01180         ImaIn->data[z][y] =  ImaIn->data[0][0] + z*ImaIn->dimy*ImaIn->dimx + y*ImaIn->dimx;
01181 
01182   
01183 }
01184 */
01185 
01186 
01187 

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