mdistance3d.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 "distance3d.h"
00020 #include <string.h>
00021 
00022 
00023 int main(int argc, char *argv[])
00024 {
00025   param par0, *ptp;      /* tete et pointeur pour la chaine de parametres */
00026   carte_distance3d_t des; /*descripteur pour l'operateur de calcul de carte de distance*/
00027   char NomFicSortant [50]; /*fichier pour la sauvegarde du resultat*/
00028   ima3Du4 ima;
00029   ima3Du1 imaRes;
00030   unsigned x,y,z;
00031 
00032 
00033   /*--------lecture des paramètres-------------*/
00034   param_debut(argc, argv, &par0); 
00035   ptp = &par0;      /* regle : ptp pointe sur la structure du parametre suivant */
00036 
00037   ptp = carte_distance3d_lect( &des, ptp, ">>distance:");
00038 
00039   //lec_param(">>entrer le chemin et le nom de l'image resulat", ptp);
00040   //strcpy(NomFicSortant, ptp->rep);
00041   //ptp = ptp->next; 
00042 
00043   /* fin: sauvegarde des parametres utilises en mode MANUEL ou FICHIER */
00044   param_fin(argc, argv, &par0);
00045 
00046 
00047 
00048   /*-------Initialisation-------------*/
00049   carte_distance3d_init( &des);
00050   printf("fin_init\n");
00051 
00052   /*creation d'une image de test*/
00053   ima.dimx = 100;
00054   ima.dimy = 100;
00055   ima.dimz = 100;
00056   allouer_ima3Du4(&ima);
00057  
00058   for(z=0; z<ima.dimz; z++)
00059     for(y=0; y<ima.dimy; y++)
00060       for(x=0; x<ima.dimx; x++)
00061         ima.data[z][y][x] = 1000000;
00062 
00063   ima.data[ima.dimz/2][ima.dimy/2][ima.dimx/2] = 0;
00064 
00065 
00066   /*lancement du calcul sur l'image de test*/
00067   printf("debut_calc\n");
00068   carte_distance3d_calc( &des, &ima);
00069   printf("fin_calc\n");
00070 
00071 
00072   /*sauvegarde des résultats en passant par une image 8bits*/
00073   imaRes.dimz = ima.dimz;
00074   imaRes.dimy = ima.dimy;
00075   imaRes.dimx = ima.dimx;
00076   imaRes.lgtete = 24;
00077   imaRes.dept = 8;
00078   allouer_ima3Du1(&imaRes);
00079 
00080   /*copie de l'image résultat avec troncature a 255*/
00081   for(z=0; z<ima.dimz; z++)
00082     for(y=0; y<ima.dimy; y++)
00083       for(x=0; x<ima.dimx; x++)
00084         if( (ima.data[z][y][x]/43) <= 255 )
00085           imaRes.data[z][y][x] = (unsigned char)(ima.data[z][y][x]/43);
00086         else
00087           imaRes.data[z][y][x] = 255;
00088 
00089   for(x=0; x<ima.dimx; x++)
00090     printf("%d--", ima.data[ima.dimz/2][ima.dimy/2][x]);
00091 
00092   /*ecriture image dans un fichier*/
00093   write_volume_u1( "test_distance.lvf", &imaRes);
00094 
00095 
00096 }

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