Etiquettage d'une image en c++
Bonjour,
Debutant en c++ , je travaille sur linux...
je suis actuellement sur un programme en c++, qui permet d'identifier plusieurs objet de la même couleur dans une image, ces objets apparaissent blanc sur fond noire.
Je cherche donc a les différencier en utilisant une fonction étiquetage.
Je parcours donc cette image comme une matrice et pour chaque attribut identique de l'image je crée un tableau d'étiquetage. Cependant je n'arrive pas a implémenter cette fonction car j'ai de mal a comprendre comment faire étiquetage de mon image correctement.
voici mon code ....:(
Code:
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 53 54 55 56 57 58 59 60 61
| int **ett;
byte **att,**Final;
long nrl,nrh,ncl,nch;
int i,j;
int nouvelleE=1;
attribut=LoadPGM_bmatrix("resultat.pgm",&nrl,&nrh,&ncl,&nch);
ettiquette=imatrix(nrl,nrh,ncl,nch);
for(i=nrl;i<nrh+1;i++){
for(j=ncl+1;j<nch;j++){
if(att[i][j]==255)
if( (att[i][j]==att[i][j-1]) && (att[i][j] != att[i-1][j]))
{
ett[i][j-1]==nouvelleE;
ett[i][j]==ett[i][j-1];
}
else
if( (att[i][j]==att[i-1][j]) && (att[i][j]!=att[i][j-1]))
{
ett[i-1][j]==nouvelleE;
ett[i][j]==ett[i-1][j];
}
else
if((att[i][j]!= att[i][j-1])&&(att[i][j] != att[i-1][j]))
{
ett[i][j]==nouvelleE;
nouvelleE++;
}
else
if((att[i][j]== att[i-1][j]) && (att[i][j]==att[i][j-1]) &&(ett[i][j-1]==ett[i-1][j]))
{
ett[i][j] == ett[i-1][j];
}
else
if( (att[i][j]== att[i-1][j]) && (att[i][j]==att[i][j-1]) && (ett[i][j-1]!=ett[i-1][j]))
{
ett[i][j]==ett[i-1][j];
}
}
}
for(i=nrl;i<nrh+1;i++){
for(j=ncl+1;j<nch;j++){
Final[i][j]=(byte)ett[i][j]*(255/(nouvelleI-1));
}
}
SavePGM_bmatrix(Final,nrl,nrh,ncl,nch,"etiquettage.pgm"); |