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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| IplImage *img;
IplImage *img_nb;
CvScalar pixel1;
CvScalar pixel2;
int i,j,k,l,m,n;
int ptComp = 0, gdComp = 0; // compteurs pour recherche de doublons
int carre1[15][15];
int carre2[15][15]; // servent pour la recherche de doublons
// DEBUT DE L'ANALYSE : RECHERCHE DE DOUBLONS
for (i=0 ; i < img_nb->width - 15 ; i++)
{
for (j=0 ; j < img_nb->height - 15 ; j++) // boucles i et j : pour le 1er carré
{
for (k=0 ; k < img_nb->width - 15 ; k++)
{
for (l=0 ; l < img_nb->height - 15 ; l++) // boucles k et l : pour le second carré
{
ptComp = 0;
for (m=0 ; m < 15 ; m++)
{
for (n=0 ; n < 15 ; n++) // boucles m et n : longueur des arêtes des carrés
{
if (!((i==k) && (j==l))) // on supprime la cas où les 2 carrés se situent au même emplacement
{
//printf("VALIDATION : avant cvGet2D pixel1.\n");
pixel1 = cvGet2D(img_nb, j+n, i+m); // BUG ICI ?
pixel2 = cvGet2D(img_nb, l+n, k+m);
carre1[m][n] = pixel1.val[0];
carre2[m][n] = pixel2.val[0];
if (carre1[m][n] == carre2[m][n]) ptComp++;
}
//printf("VALIDATION:fin boucle n. Valeur de i=%d,j=%d,k=%d,l=%d,m=%d,n=%d,ptC=%d.\n", i,j,k,l,m,n,ptComp);
}
}
if (ptComp == (15*15)) gdComp++; // il faut que les 255 pixels des 2 carrés soient égaux, alors on a une trace d'un doublon
}
}
}
}
if (gdComp > 0) printf("Nous avons trouve %d doublons possibles dans l'image.\n\n", gdComp);
if (gdComp == 0) printf("Aucun doublon repere.\n\n");
system("PAUSE");
// FIN DE L'ANALYSE : RECHERCHE DE DOUBLONS |
Partager