mcontourRSO_u2.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 */
00029 #include "image.h"    /* types des donnees manipulees dans ima2D */
00030 #include "proto2D.h"  /* descripteurs et prototypes des fonctions de ima2D */
00031 #include "contourRSO.h"  /* complement pour le operateur detecteur de contour */ 
00032 #include <stdlib.h>
00033 
00034 
00035 int main(int argc, char *argv[]){
00036   int i, j;
00037   float tmpfl;
00038 
00039 /* DECLARATIONS */
00040   /* images */ 
00041   imau2 im0;
00042   imafl imvalfl;
00043   imau1 imvalu1;
00044   imau1 imdir;
00045   /* operateurs */
00046   read_ima_t rea;
00047   contourRSO_t cont;
00048   write_ima_t wri1;
00049   write_ima_t wri2;
00050   add_colormap_t col;
00051   param par0, *ptp;
00052 
00053 /* LECTURE PARAMETRES */
00054   param_debut(argc, argv, &par0); 
00055   ptp = &par0;  
00056   /* operateurs: ptp est passe en argument, return fournit la nouvelle position */
00057   ptp = read_ima_lect(&rea, ptp, ">> image initiale (u2):");
00058   ptp = contourRSO_lect(&cont, ptp, ">> contours :");
00059   ptp = write_ima_lect(&wri1, ptp, ">> image resultat, ratio (u1/fl) :");
00060   ptp = write_ima_lect(&wri2, ptp, ">> image resultat, direction (u1) :");
00061   ptp = add_colormap_lect(&col, ptp, ">> LUT direction normale au contour :"); 
00062   /* fin: sauvegarde des parametres utilises en mode MANUEL ou FICHIER */
00063   param_fin(argc, argv, &par0);
00064 
00065 /* INITIALISATION  */
00066   /* operateur */
00067   read_imau2_init(&rea, &im0);
00068   contourRSOu2_init(&cont, im0, &imvalfl, &imdir);
00069   write_ima_init(&wri1);
00070   write_ima_init(&wri2);
00071   add_colormap_init(&col);
00072 
00073 /* CALCUL */
00074    contourRSOu2_calc(&cont, im0, &imvalfl, &imdir);
00075    if(strcmp(wri1.ext, "ima") == 0 || strcmp(wri1.ext, "ras") == 0){
00076        imvalu1.nr = imvalfl.nr;
00077        imvalu1.nc = imvalfl.nc;
00078        alloc_imau1(&imvalu1);
00079        for(i=0; i<imvalfl.nr; i++)
00080            for(j=0; j<imvalfl.nc; j++){
00081                tmpfl = imvalfl.p[i][j]*255.999;
00082                if(tmpfl < 256)
00083                    imvalu1.p[i][j] = (pixu1)tmpfl;
00084                else
00085                    imvalu1.p[i][j] =255;
00086            }
00087    }
00088    add_colormap_calc(&col, &imdir);
00089     
00090 /* FREMETURE */
00091    if(strcmp(wri1.ext, "ima") == 0 || strcmp(wri1.ext, "ras") == 0){
00092        write_imau1_ferm(&wri1, imvalu1);
00093    }
00094    else{
00095        write_imafl_ferm(&wri1, imvalfl);
00096    }
00097    write_imau1_ferm(&wri2, imdir);
00098   
00099 }
00100 

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