filtre::filtre(const IplImage& image): img(image) { nbLigne = nbColonne = 3 ; GH.resize(getNbLigne() ); GV.resize(getNbLigne() ); Diag.resize(getNbLigne() ); for (int i = 0; i < getNbLigne(); ++i) { GH[i].resize(getNbColonne() ); GV[i].resize(getNbColonne() ); Diag[i].resize(getNbColonne() ); } }
SPlateau* plateau_chargement(FILE* fichier) { SPlateau* plateau = malloc(sizeof(SPlateau)); plateau->grille = chargerMatrice(fichier); if(plateau->grille) { printf("BON \n"); plateau->taille = getNbLigne(plateau->grille); } else { printf("PAS BON \n"); free(plateau); plateau = NULL; } return plateau; }
/* *Fonction qui créé la patch de coup minimal entre deux fichiers * @param fichier initial * @param fichier final * @param patch */ int main(int argc, char** argv) { if (argc != 3 ) { printf("./bin fichier1 fichier2"); return 0; } int nbLigne1; int nbLigne2; int taillePlusLongueLigne = 0; getNbLigne(&nbLigne1, &taillePlusLongueLigne, argv[1]); getNbLigne(&nbLigne2, &taillePlusLongueLigne, argv[2]); FILE* fichier1 = fopen(argv[1],"r"); FILE* fichier2 = fopen(argv[2],"r"); /*Recupération des données*/ char** tab1; char** tab2; tab1 = malloc(nbLigne1*sizeof(char*)); tab2 = malloc(nbLigne2*sizeof(char*)); char* RetourLigne; for (int i =0; i<nbLigne1 ; i++ ) { tab1[i] = malloc(taillePlusLongueLigne*sizeof(char)); fgets(tab1[i],taillePlusLongueLigne, fichier1); RetourLigne = strstr(tab1[i], "\n"); if (RetourLigne == NULL) { strcat(tab1[i], "\n"); } } for (int j =0; j< nbLigne2; j++) { tab2[j] = malloc(taillePlusLongueLigne*sizeof(char)); fgets(tab2[j],taillePlusLongueLigne, fichier2); RetourLigne = strstr(tab2[j], "\n"); if (RetourLigne == NULL) { strcat(tab2[j], "\n"); } } fclose(fichier1); fclose(fichier2); /*Recherche du patch de cout minimal*/ data** tabBellMan;//[nbLigne1 + 1][nbLigne2 + 1]; tabBellMan = malloc((nbLigne1+1)*sizeof(data)); for(int i = 0; i<=nbLigne1;i++) { tabBellMan[i] = malloc((nbLigne2+1)*sizeof(data)); } for (int k = 0;k<=nbLigne1; k++ ) { for (int l = 0; l<= nbLigne2; l++) { tabBellMan[k][l].valeur = -1; //cette valeur correspond a une case non traité strcpy(tabBellMan[k][l].commande,""); } } //Cette chaine de caractère contient en réalité la suite des instructions a effectuer dans le patch char instructions[10000]; int res = B(1, 1, tabBellMan,nbLigne1, nbLigne2, tab1, tab2, &instructions); //On ecrit le patch sur la sortie //peut etre write serait mieux : write(1,instructions); 1= sortie standar, 2= sortie d erreur. printf(instructions); for (int i=0; i<nbLigne1; i++) { free(tab1[i]); } for (int j=0; j<nbLigne2; j++) { free(tab2[j]); } for(int k=0; k<=nbLigne1;k++) { free(tabBellMan[k]); } free(tabBellMan); free(tab1); free(tab2); return res; }