int main(int argc, char **argv) { int n, k; double pas; double *x, *y, *x0, *x1, *tmp; struct info_t info; const char *donnees = argv[1]; /* le fichier des donnees bruitees */ n = atoi(argv[2]); /* nombre de donnees bruitees */ pas = 1./n; init_info(n, &info); x = (double*)malloc((n+2)*sizeof(double)); y = (double*)malloc((n+2)*sizeof(double)); lire_fichier(donnees, x, &info); x0 = x; x1 = y; for( k = 1 ; k <= KMAX ; k++ ) { lissage(x0, &info, x1); tmp = x0; x0 = x1; x1 = tmp; } ecrire_fichier("lissage.txt", x0, &info); free(x); free(y); return 0; }
traiter (struct s_record r[], int n, int p) { long l[40], dl[40], ldl[40]; /* lissage */ int i; long cia, li1, t, ab, dl1, inv; char buf[30]; /* traiter1 (r); */ l[0] = r[0].clot; for (i=1; i<n; i++) { /* r[i].l = l[i] = ( r[i].clot * alpha_0 + l[i-1] * beta_0 ) / ( alpha_0 + beta_0 ); */ r[i].l = l[i] = lissage ( r[i].clot, l[i-1], (i>1)?l[i-2]:l[i-1], alpha_0, beta_0, gamma_0, delta_0 ); r[i].dl = dl[i] = l[i] - l[i-1]; if (i == 1) r[i].ldl = ldl[i] = dl[i]; else /* r[i].ldl = ldl[i] = ( dl[i] * alpha_1 + ldl[i-1] * beta_1 ) / ( alpha_1 + beta_1 ); */ r[i].ldl = ldl[i] = lissage ( dl[i], ldl[i-1], (i>2)?ldl[i-2]:ldl[i-1], alpha_1, beta_1, gamma_1, delta_1 ); /* printf (" %ld,%ld ", r[i].clot, l[i]); */ /* printf ("\n"); printf ("ci * alpha = %ld\n", cia = r[i].clot * alpha); printf ("li-1 * beta = %ld\n", li1 = l[i-1] * beta); printf ("total = %ld\n", t = cia + li1); printf ("alpha + beta = %d\n", ab = alpha + beta); printf ("rapport : %ld\n", t / ab); printf ("\n"); */ /* printf ("%ld %ld %ld %ld %ld %ld\n", r[i].clot, l[i-1], r[i-1].l, r[i].l, r[i].dl, r[i].ldl); */ /* gets (buf); */ } /* gets (buf); */ /* dl = l[n-1] - l[n-2]; */ dl1 = ldl[/*n*/ p - 1]; if (dl1 == 0) inv = INF; else inv = l[/*n*/p - 1] / dl1; /* printf ("%s %ld %ld %ld %ld\n", r[0].nom, l[n-1], l[n-2], dl, mdl); */ /*if (dl > mdl && dl < 300000) { mdl = dl; printf ("%s %ld %d %ld %ld\n", r[0].nom, dl, n, l[n-1], l[n-2]); memcpy (&mrecords, r, sizeof(mrecords)); }*/ if ((n > 1) && (inv > 0) && (inv < minv)) { minv = inv; mdl = dl1; /* printf ("%s %ld %ld %d %ld %ld\n", r[0].nom, inv, dl1, n, l[p - 1], l[p - 2]); */ memcpy (&mrecords, r, sizeof(mrecords)); nm = n; } if (max_inv && inv < max_inv /*20*/ && inv > 1 && command[0] == 'm') { if (command[1] == 'g') { init_graph (/*16*/ GRAPHMODE); printf ("%s %ld %ld %d %ld %ld\r", r[0].nom, inv, dl, n, l[n-1], l[n-2]); graph (r); gets (buf); } else printf ("%s %ld %ld %d %ld %ld\n", r[0].nom, inv, dl, n, l[n-1], l[n-2]); } /* printf ("\n"); */ if (command[0] == 'g') { if (command[1] == 0 || !strncmp (command+1, r[0].nom, strlen(command+1))) { init_graph (/*16*/ GRAPHMODE); graph (r); gets (buf); } } }
int main(int argc, char const *argv[]) { //Pour effacer l'ecran effacer_ecran(); ligne_separation('='); char nomImage[255] = ""; char transformation[255] = ""; // On ouvre le fichier de l'image FILE* file_image = ouverture_lecture_fichier_image(&argc,argv,nomImage,transformation); if(file_image == NULL) return 1; IMAGE tab_pixels; if(lecture_fichier(file_image, &tab_pixels, nomImage)){ printf("\tNombre de Colonnes:\t%d\n\tNombre de Lignes:\t%d\n\tValeur Maximal:\t\t%d\n",tab_pixels.nb_col,tab_pixels.nb_lig,tab_pixels.max_val); printf("[O]\tLecture complete du fichier image reussie\n"); } else{ printf("[X]\tProbleme de lecture du fichier image\n"); return 1; } file_image = NULL; // ########################################### // Travail des fonctions des transformations // ########################################### // Raccourcis pour que l'utilisateur rentre la transformation lors de l'execution en ligne de commande int transfoOk = 1; if(strcmp(transformation, "niveauGris") == 0) niveauGris(&tab_pixels); else if(strcmp(transformation, "binarisation") == 0) binarisation(&tab_pixels); else if(strcmp(transformation, "symetrieH") == 0) symetrie_horizontale(&tab_pixels); else if(strcmp(transformation, "symetrieV") == 0) symetrie_verticale(&tab_pixels); else if(strcmp(transformation, "negatif") == 0) negatif(&tab_pixels); else if(strcmp(transformation, "redimensionnement") == 0) redimensionnement(&tab_pixels, argc, argv); else if(strcmp(transformation, "ameliorationContraste") == 0) amelioration_du_contraste(&tab_pixels); else if(strcmp(transformation, "lissage") == 0) lissage(&tab_pixels); else if(strcmp(transformation, "laplacien") == 0) laplacien(&tab_pixels); else if(strcmp(transformation, "gradientSimple") == 0) gradient(&tab_pixels, transformation); else if(strcmp(transformation, "gradientSobel") == 0) gradient(&tab_pixels, transformation); else if(strcmp(transformation, "detectionContoursSobel") == 0) detectionContoursSobel(&tab_pixels); else if(strcmp(transformation, "detectionContoursLaplacien") == 0) detectionContoursLaplacien(&tab_pixels); else if(strcmp(transformation, "reductionBruit") == 0) reductionBruit(&tab_pixels); else if(strcmp(transformation, "masqueCustom") == 0) masqueCustom(&tab_pixels, argc, argv); else if(strcmp(transformation, "base") != 0){ printf("[X]\tTransformation inexistante\n"); transfoOk = 0; } // ########################################### if(transfoOk){ file_image = ouverture_ecriture_fichier_image(&(tab_pixels.type),nomImage,transformation); if(file_image == NULL) return 1; if(ecriture_fichier(file_image,&tab_pixels,nomImage,transformation)) printf("[O]\tEcriture du fichier reussie, transformation sauvegardee\n"); else printf("[X]\tEcriture du fichier rate, transformation non sauvegardee\n"); } // On libère le tableau de pixels vider_tab_pixels(&tab_pixels); ligne_separation('='); return 0; }