/*------------------------------------------------------*/ /* Prog : ProgDemo5.c */ /* Auteur : */ /* Date : */ /* version : */ /* langage : C */ /* labo : DIRO */ /*------------------------------------------------------*/ /*------------------------------------------------*/ /* FICHIERS INCLUS -------------------------------*/ /*------------------------------------------------*/ #include #include #include #include #include "FonctionDemo.h" /*------------------------------------------------*/ /* DEFINITIONS -----------------------------------*/ /*------------------------------------------------*/ #define NAME_IMG_IN "lenna" #define NAME_IMG_OUT1 "ImgOut1" #define NAME_IMG_OUT2 "ImgOut2" #define WIDTH 128 #define LENGTH 128 /*------------------------------------------------*/ /* PROGRAMME PRINCIPAL -------------------------*/ /*------------------------------------------------*/ main() { int i,j,k; float** Mat1; float** Mat2; float** Mat3; float* VectHist; /*Allocation memoire pour la matrice image*/ Mat1=fmatrix_allocate_2d(LENGTH,WIDTH); Mat2=fmatrix_allocate_2d(LENGTH,WIDTH); Mat3=fmatrix_allocate_2d(LENGTH,WIDTH); VectHist=fmatrix_allocate_1d(256); /*Initialisation a zero de toutes les matrices */ for(i=0;i */ /* mat : matrice contenant l'image */ /* lgth,wdth : Longueur & Largeur de la matrice */ /* var : Variance du bruit gaussien */ /* ----------------------------------------------------------- */ /* Sortie -> */ /* mat : Matrice avec ajout du bruit gaussien */ /****************************************************************************/ /****************************************************************************/ /* Ajoute du bruit impulsionnel dans la matrice mat */ /* add_impulse_noise(float** mat,int lgth,int wdth,float pourc) */ /* -------------------------------------------------------- */ /* Entree -> */ /* mat : matrice contenant l'image */ /* lgth,wdth : Longueur & Largeur de la matrice */ /* pourc : Pourcentage de bruit gaussien */ /* ----------------------------------------------------------- */ /* Sortie -> */ /* mat : Matrice avec ajout du bruit impulsionnel */ /**************************************************************************** /*-------- FIN ---------------------------------------------*/ /*----------------------------------------------------------*/ /*Sauvegarde des matrices sous forme d'image pgm*/ SaveImagePgm(NAME_IMG_OUT1,Mat1,LENGTH,WIDTH); SaveImagePgm(NAME_IMG_OUT2,Mat2,LENGTH,WIDTH); /*Liberation memoire pour les matrices*/ free_fmatrix_2d(Mat1); free_fmatrix_2d(Mat2); free_fmatrix_2d(Mat3); free_fmatrix_1d(VectHist); /*Commande systeme: visualisation de Ingout.pgm*/ system("xview ImgOut1.pgm&"); system("xview ImgOut2.pgm&"); /*retour sans probleme*/ printf("\n C'est fini ... \n\n\n"); return 0; }