lbidon.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 */
00019 /* **************************** lbidon.c ******************************/
00020 /*                                                                    */
00021 /* ********************************************************************/
00022 
00042 #include "image.h"
00043 #include "proto2D.h"
00044 #include "bidon.h"
00045 #include <stdlib.h>
00046 #include <string.h>
00047 
00048 /* *************************  LECTURE  *******************************/
00062 param *bidon_lect( bidon_t *des, param *ptp, char *debq){
00063   char question[500];
00064 
00065   sprintf(question, "%s dimX (entier)", debq); 
00066   lec_param(question, ptp);
00067   des->dimX = atoi(ptp->rep);
00068   ptp = ptp->next;
00069 
00070   sprintf(question, "%s dimY (entier)", debq); 
00071   lec_param(question, ptp);
00072   des->dimY = atoi(ptp->rep);
00073   ptp = ptp->next;
00074 
00075   sprintf(question, "%s gain (reel)", debq); 
00076   lec_param(question, ptp);
00077   des->gain = (float)atof(ptp->rep);
00078   ptp = ptp->next;
00079 
00080   sprintf(question, "%s forme (nom)", debq); 
00081   lec_param(question, ptp);
00082   strcpy(des->forme, ptp->rep);
00083   ptp = ptp->next;
00084 
00085   return(ptp);
00086 }
00087 
00088 /* *************************  INITIALISATION  ***************************/
00100 int bidonu1_init(bidon_t *des, imau1 im0, imau1 *imres){
00101   int i, j;
00102  
00103   /* image resultat */ 
00104   imres->nc = im0.nc;
00105   imres->nr = im0.nr;
00106   sprintf(imres->nom, "%s_bidon_%dx%d", im0.nom, des->dimX, des->dimY);
00107   alloc_imau1(imres);
00108 
00109   /* variables de l'operateur */
00110   des->msq.nc = des->dimX;
00111   des->msq.nr = des->dimY;
00112   alloc_imafl(&(des->msq));
00113 
00114   /* calcul du masque selon la forme */
00115   if( strcmp(des->forme, "rectangle") == 0 ){
00116       printf("\n>>bidonu1_init : masque %s %dx%d\n", 
00117              des->forme, des->dimX, des->dimY); 
00118       for(j=0; j<des->dimY; j++)
00119           for(i=0; i<des->dimX; i++){
00120               des->msq.p[j][i] = des->gain;
00121           }
00122   }
00123   else if( strcmp(des->forme, "triangle") == 0 ){
00124       printf("\n>>bidonu1_init : masque %s %dx%d\n", 
00125              des->forme, des->dimX, des->dimY); 
00126       /* ... */
00127   }
00128   else{
00129       printf("\n>>ERREUR bidonu1_init : masque %s inconnu\n", 
00130              des->forme, des->dimX, des->dimY); 
00131       exit(1);
00132   }    
00133 }
00134 
00135 
00136 /* *************************  CALCUL  ***************************/
00147 int bidonu1_calc(bidon_t *des, imau1 im0, imau1 *imres){
00148   int i, j;
00149       
00150   for(j=0; j<im0.nr; j++)
00151       for(i=0; i<im0.nc; i++)
00152           imres->p[j][i] = im0.p[j][i];
00153 
00154 }
00155 
00156   /* fin doc en sous partie */   

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