lformat_learning_set_from_imau1.c

Go to the documentation of this file.
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 /* ************************************************************************* */
00020 /*               lformat_learning_set_from_imau1.c                            */
00021 /* ************************************************************************* */
00022 /*          Opérateur créant une structure de données de type */
00023 /* learning_set à partir d'images et d'un masque de type imau1 */
00024 /*                                                                           */
00025 /* ************************************************************************* */
00026 /*                                                                           */
00027 /*  Derniere modification: 02/04/2004                                         */
00028 /*  Creer par: Ramasso E.                                        */
00029 /*                                                                           */
00030 /* ************************************************************************* */
00031 
00038 #include "format_learning_set_from_imau1.h"
00039 #include "image.h"
00040 #include "proto2D.h"
00041 #include <stdlib.h>
00042 #include <stdio.h>
00043 
00044 
00045 
00046 
00073 
00074 
00075   
00076 
00077 
00078 /* *************************  LECTURE  *******************************/
00096   param* format_learning_set_from_imau1_lect(
00097                                   format_learning_set_from_imau1_t *desc_format, 
00098                                   param *ptp,
00099                                   char *debq                                       
00100                                   )
00101   {
00102     char question[500];
00103     int i;
00104     
00105     /* nb attributs */
00106     sprintf(question, "%s Nombre d'attributs ", debq);
00107     lec_param(question, ptp);
00108     desc_format->nb_att = atoi(ptp->rep);
00109     ptp = ptp->next;
00110     
00111     if(desc_format->nb_att == 0)
00112       {
00113         printf("Nb Att = 0!!\n\n");
00114         exit(1);
00115       }
00116     
00117     /* lire attributs */
00118     if((desc_format->att_rea = (read_ima_t*)malloc(desc_format->nb_att*sizeof(read_ima_t)))==NULL) 
00119       {
00120         printf("Alloc structures %d images imp.",desc_format->nb_att);
00121         exit(1);
00122       }
00123     
00124     for(i=0;i<desc_format->nb_att;i++)
00125       {
00126         printf("\nChemin de l'attributs %d/%d :",i+1,desc_format->nb_att);      
00127         ptp = read_ima_lect(&desc_format->att_rea[i], ptp, ">> Chemin de l'attribut (.ras) ");
00128       }
00129     
00130     /* formatage attributs entree en data input*/
00131     ptp = format_imau1_classifier_input_lect(&desc_format->format_des_input, ptp, ">> Format attributs->data input lecture : ");
00132     
00133     /* le masque : data output */
00134     ptp = read_ima_lect(&desc_format->masque_rea, ptp, ">> Format learning set : chemin du masque (.ras) ");
00135     
00136     /* formatage du masque */
00137     ptp = format_imau1_classifier_crisp_output_lect(&desc_format->format_des_output, ptp, ">> Format data output  lecture : ");
00138     
00139   return ptp;
00140   }
00141   
00142 
00143 
00144 
00145 
00146 
00147 
00148 /* *************************  INITIALISATION  ***************************/
00176   int format_learning_set_from_imau1_init(
00177                                format_learning_set_from_imau1_t *desc_format,
00178                                const int LABEL_FOND,
00179                                learning_set *learn
00180                                )
00181   {
00182 
00183     int i,j,k;   //indices de boucle
00184     int stop;   //pour while
00185     int l;   //reponse utilisateur
00186     int indice_c_max; //contient l'indice de la classe a rejeter (pas le label)
00187 
00188     printf("\nInitialisation de learning set...\n\n");
00189   
00190     
00191   /* --------------------------------------------
00192      les attributs
00193      -------------------------------------------*/
00194     
00195   printf("Traitement des attributs...\n");
00196   
00197   /* alloc des attributs */
00198   if((desc_format->att_ima = (imau1*)malloc(desc_format->nb_att*sizeof(imau1))) == NULL)
00199     {
00200       printf("\nAlloc images entrées impossible\n");
00201       exit(1);
00202     }
00203 
00204   /* init des attributs */
00205   for(i=0;i<desc_format->nb_att;i++)
00206     read_imau1_init(desc_format->att_rea+i,desc_format->att_ima+i);
00207   
00208   /* verifier si bonne dimension pour attributs */
00209   for(i=0;i<desc_format->nb_att;i++)
00210     format_imau1_classifier_input_init(&desc_format->format_des_input, desc_format->att_ima[i], &desc_format->dataIattributs); 
00211   
00212   /* formatage du masque*/
00213   read_imau1_init(&desc_format->masque_rea,&desc_format->masque_ima);
00214   format_imau1_classifier_crisp_output_init(&desc_format->format_des_output,desc_format->masque_ima,&desc_format->dataOmasque);
00215   
00216   /* le remplissage de data input */
00217   for(i=0;i<desc_format->nb_att;i++)
00218     format_imau1_classifier_input_calc(&desc_format->format_des_input, desc_format->att_ima[i], &desc_format->dataIattributs);
00219 
00220   /* le remplissage de data input */
00221   format_imau1_classifier_crisp_output_calc(&desc_format->format_des_output, desc_format->masque_ima, &desc_format->dataOmasque);
00222   
00223   /* liberation des images */
00224   printf("\nLiberation des images et des structures associees...");fflush(stdout);
00225   for(i=0;i<desc_format->nb_att;i++) 
00226     free_imau1(&desc_format->att_ima[i]); 
00227   free(desc_format->att_ima); 
00228   free(desc_format->att_rea); 
00229 
00230   printf("Ok\n"); 
00231 
00232 
00233 
00234   /*-------------------------------------------
00235     dimension de l'ensemble
00236     --------------------------------------------*/
00237 
00238   /* verifier nb pts >=2 */
00239   if(desc_format->dataIattributs.nb_pts < 2 || desc_format->dataOmasque.nb_pts < 2)
00240     {
00241       printf("\n\nERREUR learning set : Pas assez de points attributs = %d et masque = %d  (<2?)\n",
00242              desc_format->dataIattributs.nb_pts,desc_format->dataOmasque.nb_pts);
00243       exit(1);
00244     }
00245 
00246   /* si pas meme dimension exit */
00247   if(desc_format->dataIattributs.nb_pts != desc_format->dataOmasque.nb_pts)
00248     {
00249       printf("\n\nERREUR : le masque et les attributs doivent comporter le meme nombre de points.\n\n");
00250       printf("desc_format->dataIattributs.nb_pts = %d - desc_format->dataOmasque.nb_pts = %d\n",desc_format->dataIattributs.nb_pts,desc_format->dataOmasque.nb_pts);
00251       printf("desc_format->dataIattributs.equ_nb_rows = %d - desc_format->dataOmasque.equ_nb_rows = %d\n",desc_format->dataIattributs.equ_nb_rows,desc_format->dataOmasque.equ_nb_rows);
00252       printf("desc_format->dataIattributs.equ_nb_cols = %d - desc_format->dataOmasque.equ_nb_cols = %d\n",desc_format->dataIattributs.equ_nb_cols,desc_format->dataOmasque.equ_nb_cols);
00253       exit(1);
00254     }
00255 
00256 
00257   /*------------------------------------------------
00258     les classes : label et nb pts/label
00259     -----------------------------------------------*/
00260 
00261   /* au moins 1 classe dans le masque : le fond ou l'objet */
00262   learn->output_ref.nb_class = 1;
00263 
00264   /* allocation champ contenant info sur les classes */
00265   if((desc_format->classes = (une_classe *)malloc(1*sizeof(une_classe))) == NULL)
00266     {
00267       printf ("\n\nERREUR learning set : allocation classes learn impossible\n");  
00268       exit(1);
00269     }
00270 
00271   /* le premier point des donnees est le premier label */
00272   desc_format->classes[0].label = desc_format->dataOmasque.classes.crisp[0];
00273   desc_format->classes->nb_pts  = 1;
00274 
00275   /* calcul nombre de classes et nombre de points pour allocation */
00276   j = 1;
00277 
00278   //printf("nb pts att = %d\n",desc_format->dataIattributs.nb_pts);
00279   //printf("nb att = %d\n",desc_format->nb_att);
00280   /* pas prendre le premier point (deja fait) => i=1 */
00281   for(i=1;i<desc_format->dataIattributs.nb_pts;i++)
00282     {
00283       //printf("masque[%d] = %d\n",i,desc_format->dataOmasque.classes.crisp[i] );
00284       /* verif */
00285       k=0;
00286       while(k< learn->output_ref.nb_class)
00287         {
00288           /* label deja vu */
00289           if(desc_format->classes[k].label == desc_format->dataOmasque.classes.crisp[i])
00290             {
00291               desc_format->classes[k].nb_pts++;
00292              
00293               /* sort */
00294               break;
00295             }
00296           else
00297             {
00298               k++;
00299               /* si on a tout parcouru alors nouvelle classe */
00300               if(k == learn->output_ref.nb_class)
00301                 {
00302                   /* recopier les structures */
00303                   learn->output_ref.nb_class++;
00304                   if((desc_format->classes = 
00305                       (une_classe *)realloc(desc_format->classes, (learn->output_ref.nb_class)*(sizeof(une_classe)))) == NULL)
00306                     {
00307                       printf ("\n\nERREUR learning set : reallocation classes impossible\n");  
00308                       exit(1);
00309                     }
00310 
00311                   desc_format->classes[k].nb_pts = 1;
00312                   desc_format->classes[k].label = desc_format->dataOmasque.classes.crisp[i];
00313                   break;
00314                 }
00315             }
00316         }
00317     }
00318 
00319 
00320   /* si une seule classe alors pas d'interet de continuer */
00321   if(learn->output_ref.nb_class == 1)
00322     {
00323       printf("\n\nERREUR learning set : Il n'y a visiblement qu'une seule classe, \n");
00324       printf("donc tous les points sont dans la meme classe. Pas d'interet.\n");
00325       exit(1);
00326     }
00327  
00328   /* cherche la classe avec le plus grand nombre de points */
00329 
00330   /* init */
00331   indice_c_max = 0;
00332   desc_format->c_max = desc_format->classes[indice_c_max].label;
00333   
00334   /* recherche */
00335   for(i=1;i<learn->output_ref.nb_class;i++)
00336     {
00337       if(desc_format->classes[i].nb_pts > desc_format->classes[indice_c_max].nb_pts) 
00338         {
00339           desc_format->c_max = desc_format->classes[i].label;
00340           indice_c_max = i;
00341         }
00342     }
00343 
00344   
00345   if(desc_format->c_max != LABEL_FOND)
00346     {
00347       printf("\n---------------------------------------------------------------------\n");
00348       printf("\nATTENTION \nLe label du fond specifie en parametre de la fonction init \n");
00349       printf("de l'operateur format_learning_set_from_imau1 est different\n");
00350       printf("de celui detecte par la fonction.");
00351       
00352       /*-----------------------------------------------------
00353         quel est le label du fond ?
00354         -----------------------------------------------------*/
00355       
00356       /* Prendre le label a exclure pour le fond */
00357       /* par DEFAUT le grand nombre de points */
00358       printf("\n\nINFO : La classe avec le label '%d' est prise comme le fond et ne sera pas\n",
00359              desc_format->classes[indice_c_max].label);
00360       printf("prise dans les donnees d'apprentissage vu qu'elle est celle \n");
00361       printf("avec le plus grand nombre de points (%d points sur un total de %d). \n",
00362              desc_format->classes[indice_c_max].nb_pts,desc_format->dataIattributs.nb_pts);
00363       printf("Seulement les autres classes seront incluses dans le learning set.\n");
00364       printf("\nAcceptez (1 + <enter>) ou changez le label a exclure (0 + <enter>) ? : ");
00365       scanf("%d",&l);
00366       
00367       stop = 0;
00368       while(stop == 0)
00369         {
00370           switch(l)
00371             {       
00372         case 0 : /* changer le label a exclure */
00373           while(stop == 0)
00374             {
00375               printf("\nLes differents labels sont : \n");
00376               /* affichage et reponse */
00377               for(i=0;i<learn->output_ref.nb_class;i++)
00378                 printf("                               label %d (%d points)  \n",desc_format->classes[i].label,desc_format->classes[i].nb_pts);
00379               
00380               printf("\nNumero du label a exclure ?   :  ");
00381               scanf("%d",&desc_format->c_max);
00382               
00383               /* verification que le label est juste */
00384               i=0;
00385               while(i<learn->output_ref.nb_class)
00386                 {
00387                   if(desc_format->classes[i].label == desc_format->c_max)
00388                     {                 
00389                       stop = 1;
00390                       indice_c_max = 0;
00391                       while(desc_format->classes[indice_c_max].label != desc_format->c_max)                    
00392                         indice_c_max ++;           
00393                       break;
00394                     }
00395                   
00396                   if(i+1==learn->output_ref.nb_class)
00397                     {
00398                       printf("\nCe label n'existe pas.\n");
00399                       break;
00400                     }
00401                   
00402                   i++;
00403                 }
00404               break;
00405               
00406             case 1: /* ok */
00407               stop = 1;
00408               break;
00409               
00410             default : /* erreur */
00411               printf("\nTapez 0 (pour modifier le label de la classe de fond) ou 1 (pour continuer) : ");
00412               scanf("%d",&l);
00413               break;
00414             }
00415         }
00416         }
00417     }
00418   
00419 
00420 
00421   /* ------------------------------------------------------------------
00422   init champs des structures dataI et dataO avant allocation  
00423   ------------------------------------------------------------------*/
00424 
00425   printf("\nInit champs de la structure..."); fflush(stdout);
00426   
00427   /* les input et output ont le meme nombre de points */
00428   /* egal au nombre de points total (desc_format->rows*col) - le nombre de points */
00429   /* dans le label a rejeter (fond) */
00430   /* indice_c_max contient l'indice de la classe a rejeter (pas le label) */
00431   learn->input_ref.nb_pts = desc_format->dataIattributs.nb_pts - desc_format->classes[indice_c_max].nb_pts;
00432   learn->output_ref.nb_pts = learn->input_ref.nb_pts;
00433 
00434   /* le nombre d'attributs est le meme qu'au depart */
00435   learn->input_ref.nb_attr = desc_format->dataIattributs.nb_attr;
00436 
00437   /* le nombre de classes pour l'allocation de output */
00438   desc_format->dataOmasque.nb_class = learn->output_ref.nb_class;
00439   
00440   /* -1 pour enlever le fond */
00441   learn->output_ref.nb_class -= 1;
00442   
00443   /* le type de donnees pour l'allocation */
00444   learn->output_ref.type = CRISP_CHOICE;
00445   
00446   printf("Ok\n");
00447 
00448  /* ------------------------------------------------------------------
00449   allocation 
00450  ------------------------------------------------------------------*/
00451 
00452   /* init structure learning set */
00453   printf("Allocations datainput et dataoutput...");fflush(stdout);
00454 
00455   /* allocation de la structure input : donnees */
00456   alloc_classifier_data_input_completely(&learn->input_ref);
00457   
00458   /* allocation de la structure output : classes */
00459   alloc_classifier_data_output(&learn->output_ref);
00460 
00461   
00462   printf("\n\n---------------    RAPPORT  DES LEARNING DATA  ------------------- \n");
00463 
00464   /* nombre de points total */
00465   printf("\nDonnees initiales : %d points et %d attributs\n",
00466          desc_format->dataIattributs.nb_pts,desc_format->dataIattributs.nb_attr);
00467 
00468   /* nombre de classes */
00469   printf("\n%d classes ont ete detectees :\n",learn->output_ref.nb_class);
00470 
00471   /* affichage nombre de points par label */
00472   /* fond compris => +1 */
00473   for(i=0;i<learn->output_ref.nb_class + 1;i++)
00474     printf("Le label \t %d \t contient \t %d points.\n",
00475            desc_format->classes[i].label,desc_format->classes[i].nb_pts);
00476 
00477   /* la classe fond */
00478   printf("\nLa classe avec le label %d a ete supprimee des donnees (fond).\n",
00479          desc_format->classes[indice_c_max].label );
00480 
00481   /* affichage % de points d'apprentissage par rapport au nb de points total */
00482   printf("\nIl y a %d points d'apprentissage soit %2.2f/100 des points initiaux\n\n", 
00483          learn->input_ref.nb_pts,
00484          100.0*(float)learn->input_ref.nb_pts/ (float)(desc_format->dataIattributs.nb_pts));
00485 
00486   printf("------------------------------------------------------------------------------------- \n");
00487   
00488   return NO_ERROR_FORMAT_LSFI1;
00489 }
00490 
00491 
00492 
00493 
00494 
00495 /* *************************  CALCUL  ***************************/
00506 int format_learning_set_from_imau1_calc(
00507                                         format_learning_set_from_imau1_t *desc_format,
00508                                         learning_set *learn
00509                                         )
00510 {
00511   
00512   int i,j,k;
00513   
00514 
00515  /* ------------------------------------------------------------------
00516   remplir les points
00517  ------------------------------------------------------------------*/
00518 
00519   /* remplir la structure en enlevant les points appartenant */
00520   /* a la classe fond */
00521   printf("\nRemplissage de la structure learning set avec les donnees...");fflush(stdout);
00522  
00523   /* Parcourir tous les points du masque */
00524   /* desc_format->c_max est l'indice permettant d'avoir le label a exclure */
00525   /* j indice le data du learning set */
00526   j=0;
00527   for(i=0;i<desc_format->dataIattributs.nb_pts;i++)
00528     {
00529       if(desc_format->dataOmasque.classes.crisp[i] != desc_format->c_max)
00530         {
00531           /* alors recopier output et input dans learning set */
00532           /* j est l'indice dans la nouvelle structure et i dans la nouvelle */
00533           learn->output_ref.classes.crisp[j] = desc_format->dataOmasque.classes.crisp[i];
00534         
00535           for(k=0;k<learn->input_ref.nb_attr;k++)
00536             /* j est l'indice dans la nouvelle structure et i dans la nouvelle */
00537             learn->input_ref.attributes[k][j] = desc_format->dataIattributs.attributes[k][i];
00538   
00539           j++;    
00540         }
00541     }
00542 
00543   /* mise a jour des autres champs */
00544   learn->input_ref.equ_nb_rows = 0;
00545   learn->input_ref.equ_nb_cols = 0;
00546   learn->output_ref.equ_nb_rows = 0;
00547   learn->output_ref.equ_nb_cols = 0;
00548   learn->input_ref.begin = 0;
00549   learn->input_ref.end = 0;
00550   
00551   printf("ok\n");
00552   
00553   return NO_ERROR_FORMAT_LSFI1;
00554 
00555   }
00556 
00557 
00558 
00559 
00560 int format_learning_set_from_imau1_ferm(
00561                              format_learning_set_from_imau1_t *desc_format,
00562                              learning_set learn
00563                              )
00564 {
00565   printf("\nLiberation de la memoire allouee pour le descripteur de learning set...");
00566   free(desc_format->classes);
00567   free_data_input(&desc_format->dataIattributs);
00568   free_data_output(&desc_format->dataOmasque);
00569   printf("ok\n");
00570 
00571   printf("Liberation de la memoire allouee pour la structure de learning set...");
00572   free_data_input(&learn.input_ref);
00573   free_data_output(&learn.output_ref);
00574   printf("ok\n");
00575 
00576   return NO_ERROR_FORMAT_LSFI1;
00577 }
00578 
00579 
00581 
00582 
00583 
00584 
00585 
00586 
00587 
00588 
00589 
00590 
00591 
00592 
00593 
00594 
00595 
00596 
00597 
00626 
00627 
00628 
00629 
00630 /* *************************  LECTURE  *******************************/
00648 param *format_imau1_classifier_crisp_output_lect(
00649                                            format_imau1_classifier_crisp_output_t *desc, 
00650                                            param *ptp, 
00651                                            char *debq
00652                                            )
00653 {
00654   char question[500];
00655   int choix;
00656 
00657   sprintf(question, "%s format output : prendre image entiere (0) ou partielle (1)", debq);
00658   lec_param(question, ptp);
00659   desc->choix = atoi(ptp->rep);
00660   ptp = ptp->next;
00661 
00662 
00663   switch(desc->choix)
00664     {
00665       /* si une partie des donnees */
00666     case IMAGE_PARTIELLE :
00667 
00668       sprintf(question, "%s Coordonnées X du premier point (colonne : 0 a nb colonnes - 1)", debq);
00669       lec_param(question, ptp);
00670       desc->premier_point.Xcol = atoi(ptp->rep);
00671       ptp = ptp->next;
00672       
00673       sprintf(question, "%s Coordonnées Y du premier point (ligne : 0 a nb lignes - 1)", debq);
00674       lec_param(question, ptp);
00675       desc->premier_point.Yrow = atoi(ptp->rep);
00676       ptp = ptp->next;
00677       
00678       sprintf(question, "%s Coordonnées X deuxieme point (colonne : 0 a nb colonnes - 1)", debq);
00679       lec_param(question, ptp);
00680       desc->deuxieme_point.Xcol = atoi(ptp->rep);
00681       ptp = ptp->next;
00682       
00683       sprintf(question, "%s Coordonnées Y deuxieme point (ligne : 0 a nb lignes - 1) ", debq);
00684       lec_param(question, ptp);
00685       desc->deuxieme_point.Yrow = atoi(ptp->rep);
00686       ptp = ptp->next;
00687       
00688       break;
00689 
00690 
00691       /* mise a jour dans init */
00692     case IMAGE_ENTIERE : break;
00693 
00694       /* sinon erreur */
00695     default : 
00696       printf("\nMauvaise reponse\n"); 
00697       exit(1);
00698 
00699     }
00700 
00701   return ptp;
00702 }
00703 
00704 
00705 
00706 
00707 /* *************************  INITIALISATION  ***************************/
00728 int format_imau1_classifier_crisp_output_init(
00729                                         format_imau1_classifier_crisp_output_t *desc, 
00730                                         imau1 image_u1, 
00731                                         data_output *dataO
00732                                         )
00733 {
00734   printf("\n\nInit format crisp output...");
00735   switch(desc->choix)
00736     {
00737       /* toute l image */
00738     case IMAGE_ENTIERE :
00739       desc->premier_point.Xcol = 0;
00740       desc->premier_point.Yrow = 0;
00741       desc->deuxieme_point.Xcol = image_u1.nc - 1;
00742       desc->deuxieme_point.Yrow = image_u1.nr - 1;
00743       break;
00744 
00745       /* une partie de l image => verif dim */
00746     case IMAGE_PARTIELLE :
00747       if(!(desc->premier_point.Xcol >= 0 && desc->premier_point.Xcol < image_u1.nc &&
00748            desc->premier_point.Yrow >= 0 && desc->premier_point.Yrow < image_u1.nr &&
00749            desc->deuxieme_point.Xcol >= 0 && desc->deuxieme_point.Xcol < image_u1.nc &&
00750            desc->deuxieme_point.Yrow >= 0 && desc->deuxieme_point.Yrow < image_u1.nr &&
00751            desc->deuxieme_point.Xcol - desc->premier_point.Xcol >= 0 &&
00752            desc->deuxieme_point.Yrow - desc->premier_point.Yrow >= 0))
00753         {
00754           printf("\nErreur dimension - coordonnees points invalides\n");
00755           printf("desc->premier_point.Xcol =%d \n",desc->premier_point.Xcol);
00756           printf("desc->premier_point.Yrow =%d\n",desc->premier_point.Yrow);
00757           printf("image_u1.nr =%d\n",image_u1.nr);
00758           printf("image_u1.nc =%d\n",image_u1.nc);
00759           printf("desc->deuxieme_point.Xcol = %d\n",desc->deuxieme_point.Xcol);
00760           printf("desc->deuxieme_point.Yrow =%d\n ",desc->deuxieme_point.Yrow );
00761           exit(1);
00762         }
00763       
00764       break;
00765 
00766     default :   
00767       printf("\nErreur dans init : choix non valide\n"); 
00768       exit(1);
00769     }
00770 
00771   /* la structure de sortie est nette - crisp */
00772   dataO->type = CRISP_CHOICE;
00773   
00774   /* taille de la nouvelle image */
00775   dataO->equ_nb_cols = desc->deuxieme_point.Xcol - desc->premier_point.Xcol + 1;
00776   dataO->equ_nb_rows = desc->deuxieme_point.Yrow - desc->premier_point.Yrow + 1;
00777  
00778 
00779   /* l'image image_u1 a ete prealablement lue et initialisee => nc et nr connus */
00780   dataO->nb_pts = dataO->equ_nb_cols*dataO->equ_nb_rows;
00781 
00782   /* init pointeur sur données de sorties nettes */
00783   dataO->classes.crisp = NULL;
00784   
00785    printf("OK.\n\n");
00786   return 0;
00787 }
00788 
00789 
00790 
00791 
00792 /* *************************  CALCUL  ***************************/
00807 int format_imau1_classifier_crisp_output_calc(
00808                                         format_imau1_classifier_crisp_output_t *desc,
00809                                         imau1 image_u1, 
00810                                         data_output *dataO
00811                                         )
00812 {
00813   int i,j,k;
00814    printf("\nCalcul format crisp_output...");
00815 
00816   /* allocation de dataO-> */
00817     alloc_classifier_data_output(dataO);
00818 
00819   /* transfert des donnees de l image dans la structure de sortie */
00820   k=0;
00821   for(i=0;i<dataO->equ_nb_rows;i++)
00822     for(j=0;j<dataO->equ_nb_cols;j++)
00823       {
00824         dataO->classes.crisp[k] =
00825           (int)(image_u1.p[desc->premier_point.Yrow+i][desc->premier_point.Xcol+j]);
00826         k++;
00827       }
00828 
00829   printf("OK\n");
00830   
00831   return 0;
00832 }
00833 
00835 
00836 
00837 
00838 
00839 
00840 

Generated on Tue Apr 22 13:31:02 2008 for donnee1D by  doxygen 1.5.3