Code convolution en 2D de deux matrices:
voici les erreurs obtenus:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 void conv2(int mat1[u][v], int mat2[f][g])// fonction qui réalise la convolution en 2D de 2 matrices { int i,j,m,n,mm,nn,ii,jj,kCenterX,kCenterY,sum;// déclaration des variables // trouve la position centrale du noyau kCenterX = n/2; kCenterY = m/2; for(i=0; i < u; ++i) // lignes de mat1 { for(j=0; j < v; ++j) //colonnes de mat1 { sum = 0; // initialisation de sum à 0 for(m=0; m < f; ++m) // lignes de mat2 { mm = f - 1 - m; // indice de la ligne du noyau (mat2) retourné for(n=0; n < g; ++n) // colonnes de mat2 { nn = g - 1 - n; // indice de la colonne du noyau (mat2) retourné ii = i + (m - kCenterY); jj = j + (n - kCenterX); if( ii >= 0 && ii < u && jj >= 0 && jj < v ) { sum += in[ii][jj] * kernel[mm][nn]; } } } } } }
Dois je créer les fonctions à part?fonction.c:99:21: error: 'u' undeclared here (not in a function)
fonction.c:99:24: error: 'v' undeclared here (not in a function)
fonction.c:99:37: error: 'f' undeclared here (not in a function)
fonction.c:99:40: error: 'g' undeclared here (not in a function)
fonction.c: In function 'conv2':
fonction.c:106:16: error: 'u' undeclared (first use in this function)
fonction.c:106:16: note: each undeclared identifier is reported only once for each function it appears in
fonction.c:108:18: error: 'v' undeclared (first use in this function)
fonction.c:112:20: error: 'f' undeclared (first use in this function)
fonction.c:116:26: error: 'g' undeclared (first use in this function)
fonction.c:125:12: error: 'in' undeclared (first use in this function)
fonction.c:125:25: error: 'kernel' undeclared (first use in this function)
Partager