public void FiltreFlouPlus() { Projet_Vincent_Poupet.MyImage imagetest = new Projet_Vincent_Poupet.MyImage("coco.bmp"); Projet_Vincent_Poupet.MyImage imageresultat = new Projet_Vincent_Poupet.MyImage("coco.bmp"); int[,] matrice = new int[, ] { { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 } }; int m = 0; int n = 0; for (int i = 2; i < imageresultat.Hauteur - 2; i++) { for (int j = 2; j < imageresultat.Largeur - 2; j++) { int totalrouge = 0; int totalbleu = 0; int totalvert = 0; for (int k = i - 2; k <= i + 2; k++) { for (int l = j - 2; l <= j + 2; l++) { totalrouge = totalrouge + imageresultat.MatriceDePixels[k, l].rouge * matrice[m, n]; totalbleu = totalbleu + imageresultat.MatriceDePixels[k, l].bleu * matrice[m, n]; totalvert = totalvert + imageresultat.MatriceDePixels[k, l].vert * matrice[m, n]; n++; } m++; n = 0; } m = 0; imageresultat.MatriceDePixels[i, j].rouge = totalrouge / 25; imageresultat.MatriceDePixels[i, j].bleu = totalbleu / 25; imageresultat.MatriceDePixels[i, j].vert = totalvert / 25; } } imagetest.FiltreFlouPlus(); for (int i = 0; i < imagetest.Hauteur; i++) { for (int j = 0; j < imagetest.Largeur; j++) { Assert.AreEqual(imagetest.MatriceDePixels[i, j].rouge, imageresultat.MatriceDePixels[i, j].rouge); Assert.AreEqual(imagetest.MatriceDePixels[i, j].bleu, imageresultat.MatriceDePixels[i, j].bleu); Assert.AreEqual(imagetest.MatriceDePixels[i, j].vert, imageresultat.MatriceDePixels[i, j].vert); } } }
/// <summary> /// Bouton qui permet d'appliquer un filtre flou /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Flou(object sender, RoutedEventArgs e) { string nomfichier = this.CheminOrigine; try { Projet_Vincent_Poupet.MyImage imageflou = new Projet_Vincent_Poupet.MyImage(nomfichier); imageflou.FiltreFlouPlus(); imageflou.EnregistrerImage(this.CheminEnregistrement); } catch (Exception) { } }