mlabelcc_u1.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 */
00028 #include "image.h"    /* types des donnees manipulees dans ima2D */
00029 #include "proto2D.h"  /* descripteurs et prototypes des fonctions de ima2D */
00030 #include "labelcc.h"  /* complement pour l'operateur  labelcc */ 
00031 #include <stdlib.h>
00032 
00033 
00034 int main(int argc, char *argv[]){
00035   int i, j;
00036   int tmp;
00037 
00038 /* DECLARATIONS */
00039   /* images */ 
00040   imau1 im0;
00041   imau2 imres;
00042   imau1 imresu1;
00043   /* operateurs */
00044   read_ima_t rea;
00045   labelcc_t lab;
00046   write_ima_t wri1;
00047 
00048   param par0, *ptp;
00049 
00050 /* LECTURE PARAMETRES */
00051   param_debut(argc, argv, &par0); 
00052   ptp = &par0;  
00053   /* operateurs: ptp est passe en argument, return fournit la nouvelle position */
00054   ptp = read_ima_lect(&rea, ptp, ">> image initiale (u1):");
00055   ptp = labelcc_lect(&lab, ptp, ">> etiquetage :");
00056   ptp = write_ima_lect(&wri1, ptp, ">> image resultat, labels (u1/u2) :");
00057   /* fin: sauvegarde des parametres utilises en mode MANUEL ou FICHIER */
00058   param_fin(argc, argv, &par0);
00059 
00060 /* INITIALISATION  */
00061   /* operateur */
00062   read_imau1_init(&rea, &im0);
00063   labelccu1_init(&lab, im0, &imres);
00064   write_ima_init(&wri1);
00065 
00066 /* CALCUL */
00067    labelccu1_calc(&lab, im0, &imres);
00068    if(strcmp(wri1.ext, "ima") == 0 || strcmp(wri1.ext, "ras") == 0){
00069        imresu1.nr = imres.nr;
00070        imresu1.nc = imres.nc;
00071        alloc_imau1(&imresu1);
00072        for(j=0; j<imres.nr; j++)
00073            for(i=0; i<imres.nc; i++){
00074                 if ( (tmp=(int)(imres.p[j][i])) < 256 )
00075                         imresu1.p[j][i] = (pixu1)tmp;
00076                 else{
00077                         tmp = tmp%255;
00078                         tmp++;
00079                         imresu1.p[j][i] = (pixu1)tmp;
00080                 }
00081            }
00082    }
00083        
00084 /* FREMETURE */
00085    if(strcmp(wri1.ext, "ima") == 0 || strcmp(wri1.ext, "ras") == 0)
00086        write_imau1_ferm(&wri1, imresu1);
00087    else
00088        write_imau2_ferm(&wri1, imres);
00089    
00090 }
00091 

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