mhisto.c

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 */
00033 #include "image.h"    /* types des donnees manipulees dans ima2D */
00034 #include "proto2D.h"  /* descripteurs et prototypes des fonctions de ima2D */
00035 #include "histo.h"    /* complement pour les operateurs en cours de developpt */ 
00036 
00037 int main(int argc, char *argv[]){
00038 
00039 /* DECLARATIONS */
00040   /* images */ 
00041   imau1 im0u1;
00042   imau2 im0u2;
00043   imafl im0fl;
00044   imau1 mas;
00045 
00046   /* operateurs */
00047   read_ima_t rea, reamas;
00048   histo_t hist; 
00049 
00050   /* main : variables et parametres propres au main*/
00051   param par0, *ptp;      /* tete et pointeur pour la chaine de parametres */
00052   char nommas[200];
00053   int l, t0; 
00054 
00055 /* LECTURE PARAMETRES */
00056 
00057   /* debut: OBLIGATOIRE pour compatibilite avec les 3 modes de lecture de param */
00058   param_debut(argc, argv, &par0); 
00059   ptp = &par0;
00060   ptp = read_ima_lect(&rea, ptp, ">> image initiale :");
00061   ptp = histo_lect(&hist, ptp, ">> histograme :");
00062 
00063   /* masque facultatif => lecture du nom par read_ima impossible si reponse sans extension */
00064   lec_param(">> nom image masque type u1 (.ima|.ras), 0 si aucun masque :", ptp);
00065   strcpy(nommas, ptp->rep);
00066   ptp = ptp->next;
00067   if( hist.ngm >= 0){
00068       l = strlen(nommas);
00069       do
00070           l--;
00071       while(nommas[l] != '.'  && l>0);
00072       if( l>0 ){
00073           strncpy(reamas.nom, nommas, l);
00074           reamas.nom[l] = '\0';
00075           strcpy(reamas.ext, nommas+l+1);
00076       }
00077       else{
00078           printf("\n>>mhisto ERREUR : nom image masque incomplet (extension?)\n");
00079           exit(1);
00080       }
00081   }
00082   param_fin(argc, argv, &par0);
00083 
00084 
00085 /* INITIALISATION  */
00086 
00087   /* operateur */
00088   if( hist.ngm >= 0)
00089       read_imau1_init(&reamas, &mas);
00090 
00091   if( !strcmp(rea.ext, "ima") || !strcmp(rea.ext, "ras")){
00092       t0 = 1;
00093       read_imau1_init(&rea, &im0u1);
00094       histou1_init(&hist, im0u1, mas);
00095   }
00096   else if(!strcmp(rea.ext, "imw")){
00097       t0 = 2;
00098       read_imau2_init(&rea, &im0u2);
00099       histou2_init(&hist, im0u2, mas);
00100   }
00101   else if(!strcmp(rea.ext, "imf")){
00102       t0 = 4;
00103       read_imafl_init(&rea, &im0fl);
00104       histofl_init(&hist, im0fl, mas);
00105   }
00106   else{
00107       printf("\n >>mhisto ERREUR : extension %s inconnue\n", rea.ext);
00108       exit(0);
00109   }    
00110 
00111 /* CALCUL */
00112   switch(t0){
00113   case 1 :      
00114       histou1_calc(&hist, im0u1, mas); 
00115       break;
00116   case 2 :
00117       histou2_calc(&hist, im0u2, mas); 
00118       break;
00119   case 4 :
00120       histofl_calc(&hist, im0fl, mas); 
00121       break;
00122   }  
00123 
00124 
00125  
00126 /* FREMETURE */
00127   histo_ferm(&hist);
00128 }
00129 
00130  

Generated on Tue Apr 22 13:31:04 2008 for ima2D by  doxygen 1.5.3