From ad53ae4f6a84f2413ffe02bb90ec5bec1eb4f3ee Mon Sep 17 00:00:00 2001
From: Og <og@pop-os.localdomain>
Date: Tue, 26 Apr 2022 13:22:07 +0200
Subject: [PATCH] rapport part2 + lib matrix T = int32

---
 Matrix.h   |  2 +-
 main.c     | 12 ++++----
 rapport.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 89 insertions(+), 7 deletions(-)

diff --git a/Matrix.h b/Matrix.h
index e775a99..62fd68f 100644
--- a/Matrix.h
+++ b/Matrix.h
@@ -5,7 +5,7 @@
 #include <stdint.h>
 
 
-typedef uint16_t T;
+typedef int32_t T;
 
 
 typedef struct matrix
diff --git a/main.c b/main.c
index fe7da11..a4c1015 100644
--- a/main.c
+++ b/main.c
@@ -94,10 +94,12 @@ void Convolution_filtrage()
     // matrix* kernel = matrix_create(3,3);
     // matrix_init(kernel,3,3);
     
-    // T tab []= {0,0,0,0,1,0,0,0,0};
-    T tab []= {1,1,1,1,1,1,1,1,1};
-    // int tab []= {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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
-    // int tab[] = {0,-1,0,-1,5,-1,0,-1,0};
+    //T tab []= {0,0,0,0,1,0,0,0,0};
+    //T tab []= {1,1,1,1,1,1,1,1,1};
+    //T tab []= {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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+    //T tab[]=  {1,4,6,4,4,16,24,16,46,24,36,24,64,16,24,16,41,4,6,4,1};
+    //T tab[] = {0,-1,0,-1,5,-1,0,-1,0};
+    T tab[] = {0,-1,0,-1,4,-1,0,-1,0};
     matrix* kernel = matrix_create_from_array(3,3,tab,9);
     matrix_print(kernel);
 
@@ -109,7 +111,7 @@ void Convolution_filtrage()
 
     // pgm_write_to_file(&res,"tmp_1.pgm");
 
-    convolve_matrix(&res.pixels,&img.pixels,kernel,9);
+    convolve_matrix(&res.pixels,&img.pixels,kernel,1);
 
     int32_t norm_max = matrix_max(&res.pixels);
     int32_t norm_min = matrix_min(&res.pixels);
diff --git a/rapport.md b/rapport.md
index 787ab68..1dba380 100644
--- a/rapport.md
+++ b/rapport.md
@@ -388,4 +388,84 @@ $$\underline{\underline{A}} \times \underline{\underline{B}} = \begin{pmatrix}
 1 & 1 & 4\\
 3 & 0 & 7\\
 -4 & -11 & 2
-\end{pmatrix}$$
\ No newline at end of file
+\end{pmatrix}$$
+
+### Partie 2
+Appliquer différents filtres sur l'image suivante "part2.pgm":  
+
+![part2.pgm](img/part2.png)
+
+#### filtre F0
+\begin{equation*}
+\underline{\underline{F_0}} = \begin{pmatrix}
+0 & 0 & 0\\
+0 & 1 & 0\\
+0 & 0 & 0
+\end{pmatrix}
+\end{equation*}
+
+Résultat de la convolution obtenu:
+
+![part2_identitaire.pgm](img/part2_identitaire.png)
+
+On peux déterminer que le filtre F0 prend pas en compte les pixels dans les alentours du puxels focus (central) ce qui revient a faire une copie de la matrix sans changement. On as donc un filtre identitaire.
+
+#### filtre F1
+\begin{equation*}
+\underline{\underline{F_1}} = \frac{1}{25}\begin{pmatrix}
+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
+\end{pmatrix}
+\end{equation*}
+
+Résultat de la convolution obtenu:
+
+![part2_blur25.pgm](img/part2_blur25.png)
+
+On détermine que le filtre F1 fait la moyenne des différents pixels au alentour du focus, donc on a donc une filtre moyenneur / blur d'une matrix de 5x5. On aperçois donc bien sur l'image traitée un floutage générale.
+
+#### filtre F2
+\begin{equation*}
+\underline{\underline{F_2}} = \frac{1}{256}\begin{pmatrix}
+1 & 4 & 6 & 4 & 1\\
+4 & 16 & 24 & 16 & 4\\
+6 & 24 & 36 & 24 & 6\\
+4 & 16 & 24 & 16 & 4\\
+1 & 4 & 6 & 4 & 1
+\end{pmatrix}
+\end{equation*}
+ 
+Résultat de la convolution obtenu:
+
+![part2_blurCent.pgm](img/part2_blurCent.png)
+
+On détermine que le filtre F2 fait la moyenne des différents pixels au alentour du focus en donnant plus de point au pixels central et ceux qui lui sont le plus proches. On aperçois donc bien sur l'image traitée un floutage générale en donnant plus d'importance au détails.
+
+#### filtre F3
+\begin{equation*}
+\underline{\underline{F_3}} = \begin{pmatrix}
+0 & -1 & 0\\
+-1 & 5 & -1\\
+0 & -1 & 0
+\end{pmatrix}
+\end{equation*}
+
+Résultat de la convolution obtenu:
+
+![part2_contourF3.pgm](img/part2_contourF3.png)
+
+#### filtre F4
+\begin{equation*}
+\underline{\underline{F_4}} = \begin{pmatrix}
+0 & -1 & 0\\
+-1 & 4 & -1\\
+0 & -1 & 0
+\end{pmatrix}
+\end{equation*}
+
+Résultat de la convolution obtenu:
+
+![part2_contourF4.pgm](img/part2_contourF4.png)
\ No newline at end of file
-- 
GitLab