00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00066 #include <stdio.h>
00067 #include "image.h"
00068 #include "proto2D.h"
00069 #include "classifier.h"
00070 #include "confusion_matrix.h"
00071
00072
00073
00086 param *confusion_matrix_lect(confusion_matrix_t *desc, param *ptp, char *debq)
00087 {
00088
00089 char question[500];
00090 int i;
00091 char fich[500];
00092
00093
00094
00095 sprintf(question, " Nombre de region a etudier: ");
00096 lec_param(question, ptp);
00097 desc->nb_region_etudiee= atoi(ptp->rep);
00098 ptp = ptp->next;
00099
00100 sprintf(question, " Nom du fichier contenant l'image à évaluer: ");
00101 lec_param(question, ptp);
00102 strcpy(fich,ptp->rep);
00103 ptp = ptp->next;
00104
00105 lect_ima3Du1(fich,&(desc->imadec),ALL);
00106
00107
00108 sprintf(question, " Image de test 2D (0) ou 3D (1): ");
00109 lec_param(question, ptp);
00110 desc->type_eval= atoi(ptp->rep);
00111 ptp = ptp->next;
00112
00113 switch(desc->type_eval)
00114 {
00115 case 0:
00116
00117
00118 printf("\n Image contenant l'ensemble de test \n");
00119 ptp = read_ima_lect (&(desc->read_ima), ptp, "");
00120 read_imau1_init (&(desc->read_ima),&(desc->imaeval_2D));
00121
00122 sprintf(question, " Numero de la coupe: ");
00123 lec_param(question, ptp);
00124 desc->num_coupe= atoi(ptp->rep);
00125 ptp = ptp->next;
00126
00127
00128 break;
00129
00130 case 1:
00131
00132 sprintf(question, " Nom du fichier contenant l'ensemble de test: ");
00133 lec_param(question, ptp);
00134 strcpy(fich,ptp->rep);
00135 ptp = ptp->next;
00136
00137 lect_ima3Du1(fich,&(desc->imaeval_3D),ALL);
00138
00139 break;
00140
00141 }
00142
00143
00144 return(ptp);
00145
00146 }
00147
00163
00164
00165 void confusion_matrix_init(confusion_matrix_t *desc)
00166 {
00167 int i;
00168 int x,y,z;
00169
00170 for(z=0;z<desc->imadec.dimz;z++)
00171 for(y=0;y<desc->imadec.dimy;y++)
00172 for(x=0;x<desc->imadec.dimx;x++)
00173 {
00174 desc->imadec.data[z][y][x]=(int)(desc->imadec.data[z][y][x]*desc->nb_region_etudiee/255);
00175 }
00176 }
00177
00191
00192
00193 void confusion_matrix_calc(confusion_matrix_t *desc, int **matrice)
00194 {
00195
00196 float max;
00197 int num,x,y,z,r,i,nb;
00198 float somme;
00199
00200
00201
00202 switch(desc->type_eval)
00203 {
00204
00205 case 0:
00206
00207
00208 z=desc->num_coupe;
00209 for(y=0;y<desc->imadec.dimy;y++)
00210 for(x=0;x<desc->imadec.dimx;x++)
00211 {
00212 if(desc->imaeval_2D.p[x][y]<=desc->nb_region_etudiee && desc->imadec.data[z][y][x]<=desc->nb_region_etudiee)
00213 matrice[desc->imaeval_2D.p[x][y]][desc->imadec.data[z][y][x]]++;
00214 }
00215
00216 break;
00217
00218
00219 case 1:
00220
00221
00222
00223 for(z=0;z<desc->imadec.dimz;z++)
00224 for(y=0;y<desc->imadec.dimy;y++)
00225 for(x=0;x<desc->imadec.dimx;x++)
00226 {
00227 if(desc->imaeval_3D.data[z][y][x]<=desc->nb_region_etudiee && desc->imadec.data[z][y][x]<=desc->nb_region_etudiee)
00228 matrice[desc->imaeval_3D.data[z][y][x]][desc->imadec.data[z][y][x]]++;
00229 }
00230 break;
00231
00232 }
00233 }
00234
00235
00236
00247
00248
00249 void confusion_matrix_ferm(confusion_matrix_t *desc)
00250 {
00251 int i;
00252
00253 liberer_ima3Du1(&(desc->imadec));
00254
00255
00256 switch(desc->type_eval)
00257 {
00258 case 0:
00259
00260 free_imau1 (&(desc->imaeval_2D));
00261
00262 break;
00263
00264 case 1:
00265
00266 liberer_ima3Du1(&(desc->imaeval_3D));
00267
00268 break;
00269 }
00270
00271
00272 }
00273
00274
00275
00276
00277