/* Confusion_matrix.c ** This producergram is used to calculate a ** confusion matrix ** The output matrix includs Kappa coefficient ** COPYRIGHT: Brandt Tso */ #include #include #include #define line_max 1024 #define class_max 21 void main(void) { FILE *fin[5], *fout; unsigned int img_row, img_col; unsigned int count1, count2, gray_b, gray_u; unsigned int num_of_class,col_sum[10],total_pixel=0; double x_flo[class_max][class_max], nr[class_max][class_max]; double p1=0.5, h, user[class_max], producer[class_max]; double sumx,sum_row, sum_col, kappa, sum_rl; unsigned char store[5][line_max],in_file[50], out_file[50]; printf("\nConfusion_matrix generates the clasification confusion matrix\n"); printf("Input ground truth image:"); scanf("%s",in_file); if((fin[1] = fopen(in_file,"rb")) == NULL) { printf("Failed to open %s\n",in_file); exit(EXIT_FAILURE); } printf("Input classified image:"); scanf("%s",in_file); if((fin[2] = fopen(in_file,"rb")) == NULL) { printf("Failed to open %s\n",in_file); exit(EXIT_FAILURE); } printf("Ouput confusion matrix file name:"); scanf("%s",out_file); if((fout = fopen(out_file,"w")) == NULL) { printf("Failed to open %s\n",out_file); exit(EXIT_FAILURE); } printf("Please input the number for image rows:"); scanf("%d",&img_row); printf("Please input the number for image columns:"); scanf("%d",&img_col); printf("Please input the number of classes:"); scanf("%d",&num_of_class); for(count1=1;count1<=num_of_class;count1++) { col_sum[count1] = 0; for(count2=1;count2<=num_of_class;count2++) { nr[count1][count2] = 0; x_flo[count1][count2] = 0; } } sumx = 0; for(count1=0;count1