mM_coocur.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 */
00028 #include "image.h"    /* types des donnees utilises */
00029 #include "volume.h"   /* descripteurs et prototypes des fonctions de ima3D */
00030 #include "M_coocur.h"
00031 #include <stdlib.h>
00032 #include <math.h>
00033 #include <string.h>
00034 
00035 extern GlcmAttribute attributes[];
00036 int main(int argc, char *argv[])
00037 {
00038   /* DECLARATIONS */
00039 
00040   /* images */
00041   ima3Du1 imscr;
00042   ima3Dd *imres[total_attributes];
00043   int i, s;
00044 
00045   Mcoocur_t des;
00046 
00047   /* main : variables et parametres propres au main*/
00048   param par0, *ptp;      /* tete et pointeur pour la chaine de parametres */
00049 
00050   char *NomFicSortant;
00051   char *NomFicEntrant;
00052   char *tmp, *tmp2;
00053 
00054 /* LECTURE PARAMETRES */
00055 
00056   /* debut: OBLIGATOIRE pour compatibilite avec les 3 modes de lecture de param */
00057   param_debut(argc, argv, &par0);
00058   ptp = &par0;      /* regle : ptp pointe sur la structure du parametre suivant */
00059 
00060   /* operateurs: ptp est passe en argument, return fournit la nouvelle position */
00061   ptp = Mcoocur_lect(&des, ptp, ">>Matrice de coocurance question :");
00062 
00063   /* main : en cas de parametres lus dans le main */
00064 
00065   lec_param(">>entrer le chemin et le nom de l'image a traiter", ptp);
00066   NomFicEntrant = strdup(ptp->rep);
00067   ptp = ptp->next;
00068   lec_param(">>entrer le chemin et le nom de l'image resultat", ptp);
00069   s = strlen(ptp->rep);
00070   NomFicSortant = (char *) malloc(s + 1 + 3);
00071 
00072   // Transform filename from /path/name.ext to /path/name_%s.ext
00073   strcpy(NomFicSortant, ptp->rep);
00074   tmp2 = strrchr(NomFicSortant, '.'); // last occurence of '.' (filname extension sepparator)
00075   if (tmp2 == 0)
00076     tmp2 = NomFicSortant + strlen(NomFicSortant); // or the end of the string
00077   strcpy(tmp2, "_%s"); // %s is to be replaced with the short name of the attribute
00078   tmp2 += 3;
00079   tmp = strrchr(ptp->rep, '.');
00080   if (tmp != 0)
00081     strcpy(tmp2, tmp); // add the file extension (if any)
00082   tmp2 -= 2;
00083   ptp = ptp->next;
00084   /* fin: sauvegarde des parametres utilises en mode MANUEL ou FICHIER */
00085   param_fin(argc, argv, &par0);
00086 
00087   printf("fin de la lecture\n");
00088 
00089 /* INITIALISATION  */
00090 
00091   /* operateur */
00092   //lect_ima3Du1( NomFicEntrant, &imscr, ALL);
00093   lect_volume_u1( NomFicEntrant, &imscr);
00094   printf("Lecture image OK\n");
00095   Mcoocur_init(&des, &imscr, imres);
00096   printf("init OK\n");
00097 
00098   /* CALCUL */
00099 
00100   Mcoocur_calc(&des, &imscr, imres);
00101   printf("calc OK\n");
00102 
00103 
00104   /* FERMETURE */
00105 
00106   tmp = (char *) malloc(s + 1 + 4 + 1); // original name + _ + short name + /0
00107   for (i = 0; i < total_attributes; i++)
00108     if (des.do_output[i]) {
00109         snprintf(tmp, s + 4 + 1, NomFicSortant, attributes[i].short_name);
00110         ecr_ima3Dd(tmp, imres[i]);
00111     }
00112 }

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