Skip to content
Snippets Groups Projects
Commit ad53ae4f authored by Og's avatar Og
Browse files

rapport part2 + lib matrix T = int32

parent 69f3c008
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
#include <stdint.h>
typedef uint16_t T;
typedef int32_t T;
typedef struct matrix
......
......@@ -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);
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment