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 /* * XX = u1 | u2 : calcul d'histogramme avec lecture bloc par bloc de l'image.\\ 00020 Entree : image type u1 | u2 [+ masque de type u1]\\ 00021 Sortie : un fichier ascii avec les donnees pour representer l'histogramme\\ 00022 Description : programme pour calculer l'histogramme d'une image complete ou sur une 00023 region donnee par un niveau de gris dans un masque.\\ 00024 NB. La lecture bloc par bloc n'est pas compatible avec les images float 00025 en raison de la recherche de min/max en mode auto. Utiliser mhisto pour une lecture d'une coup 00026 des images de type u1|u2|fl.\\ 00027 Doc complete avec l'operateur (cf. lhisto).\\ 00028 @name mhistobpb_XX 00029 @author F. Bujor, E. trouve 00030 @version 1.0 (09/07/00) 00031 @see lselect_ima, lhisto et lread_ima, mhisto 00032 */ 00033 00034 #include "image.h" /* types des donnees manipulees dans ima2D */ 00035 #include "proto2D.h" /* descripteurs et prototypes des fonctions de ima2D */ 00036 #include "histo.h" /* complement pour les operateurs en cours de developpt */ 00037 00038 int main(int argc, char *argv[]){ 00039 00040 /* DECLARATIONS */ 00041 /* images */ 00042 imau2 bl0; 00043 imau1 mas; 00044 00045 /* operateurs */ 00046 select_ima_t sel, selmas; 00047 histo_t hist; 00048 00049 /* main : variables et parametres propres au main*/ 00050 param par0, *ptp; /* tete et pointeur pour la chaine de parametres */ 00051 char nommas[200]; 00052 int l; 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; 00059 ptp = select_ima_lect(&sel, ptp, ">> image initiale :"); 00060 ptp = histo_lect(&hist, ptp, ">> histograme :"); 00061 lec_param(">> nom image masque type u1 (.ima|.ras), 0 si aucun masque :", ptp); 00062 strcpy(nommas, ptp->rep); 00063 ptp = ptp->next; 00064 if( hist.ngm >= 0){ 00065 selmas = sel; 00066 l = strlen(nommas); 00067 do 00068 l--; 00069 while(nommas[l] != '.' && l>0); 00070 if( l>0 ){ 00071 strncpy(selmas.nom, nommas, l); 00072 selmas.nom[l] = '\0'; 00073 strcpy(selmas.ext, nommas+l+1); 00074 } 00075 else{ 00076 printf("\n>>mhistobpb_u2 ERREUR : nom image masque incomplet (extension?)\n"); 00077 exit(1); 00078 } 00079 } 00080 param_fin(argc, argv, &par0); 00081 00082 /* INITIALISATION */ 00083 00084 /* operateur */ 00085 select_imau2_init(&sel, &bl0); 00086 if( hist.ngm >= 0){ 00087 select_imau1_init(&selmas, &mas); 00088 } 00089 histou2_init(&hist, bl0, mas); 00090 00091 00092 /* CALCUL */ 00093 while( select_imau2_calc(&sel, &bl0) == 0){ 00094 if( hist.ngm >= 0){ 00095 if(select_imau1_calc(&selmas, &mas) != 0 ){ 00096 printf("\n>>mhistobpb_u2 ERREUR : fin du masque avant fin image\n"); 00097 break; 00098 } 00099 } 00100 histou2_calc(&hist, bl0, mas); 00101 } 00102 00103 /* FREMETURE */ 00104 histo_ferm(&hist); 00105 } 00106