Bonjour, je suis actuellement en échange au Japon et dans mon labo mon prof m'a donné a programmer la transformée de Hough pour detecter les lignes de routes dans une image. Je suis debutante en C et j ai deja demandé de l'aide plusieurs fois dans mon labo mais j'attend toujours et je n'ose plus redemander

...
Si quelqu'un peut me dire pourquoi mon code fait n'importe quoi? (il compile mais apparement quelque chose dans l'algo cloche je pense...). Merci d'avance!
extern "C"
{
#include <pgm.h>
}
#include <stdio.h>
#include <math.h>
#include <pam.h>
main(int argc, char *argv[])
{
int x, y;
int dx,dy;
int G;
FILE *infile, *outfile;
int cols, lignes, format,thetadeg,rr;
gray maxval;
gray **table1, **table2, ;//two * to have a 2 dimension table **accumulateur
int k,e,d,max,p,q,retient,bidul,s,lala,a,b,acc,rint,tint,yint,A,B,rint2,lala2;
int m=0;
int j=0;
int i=0;
double rmax,r,theta,c;
double co,pi,thetaRad;
const int m_FacteurEtalement = 20000;
int **accumulateur2= new int*[m_FacteurEtalement];
for(lala=0;lala<m_FacteurEtalement;lala++) {
accumulateur2[lala] = new int[m_FacteurEtalement];
}
if (argc!=3) {
printf("Mauvais Nombres Arguments\n");
return 0 ;
}
// Reading of the file
pgm_init(&argc, argv);
infile = pm_openr(argv[1]);
pgm_readpgminit( infile, &cols, &lignes, &maxval, &format );//reading of the file called infile
table1 = new gray*[lignes];// reservation of an espace of the memory. the espace size is "rows"/
table2 = new gray*[lignes];
for (y = 0; y <lignes; y++) {//for each ligne y
table1[y] = pgm_allocrow (cols);// reservation of a memory space with the size of one column
table2[y] = pgm_allocrow (cols);
pgm_readpgmrow( infile, table1[y], cols, maxval, format);//read but also filed the new created space (grayrow) with the original image(whiwh is in the file infile)
}
rmax=floor( sqrt(lignes^2+cols^2)+1);
//INITIALISATION IMAGE2
for(y = 0; y < lignes; y++)
{
for(x = 0; x < cols; x++){
table2[y][x]=0;
}
}
//INITIALISATION ACCUMULATEUR
for(y = 0; y < m_FacteurEtalement; y++)
{
for(x = 0; x < m_FacteurEtalement; x++)
{
accumulateur2[y][x]=0;
}
}
//INCREMENTATION ACCUMULATEUR
for(x = 0; x < lignes; x++)
{
for(y = 0; y < cols; y++)//parcours de l'image1
{
if (table1[x][y]>60 )//si le pixel est blanc
{
for (thetadeg = 0; thetadeg <360; thetadeg++)
{
thetaRad=6.28*thetadeg/360;//conversion en radian
r=x*cos(thetaRad)+y*sin(thetaRad) ; // tracage des "lignes" dans l accumulateur
rint = static_cast<int>(r); // j en fait un entier car je devrais l'utiliser comme indice de tableau
rint2=-rint;
if (-rint<m_FacteurEtalement && rint<0 )
{
accumulateur2[rint2][thetadeg]++;
}
}
}
}
}
//TRACAGE DE LIGNES DANS LA NOUVELLE IMAGE
for(rr = 0; rr < m_FacteurEtalement; rr++) //parcours de l accumulateur -------------> nombre pê a changer
{
for(thetadeg = 0; thetadeg < 360; thetadeg++)
{
if (accumulateur2[rr][thetadeg]>59) // --------------pê a changer
{
for(x = 0; x< lignes; x++) //parcours de l image2
{
thetaRad=6.28*thetadeg/360;
A=static_cast<int>((cos(thetaRad))/sin(thetaRad));
B=static_cast<int>(-rr/sin(thetaRad));
if (-A*x+B<cols && -A*x+B>0 && A!=0){
table2[x][-A*x+B]=255;
}
}
}
}
}
// Saving
outfile = pm_openw(argv[2]);
pgm_writepgminit( outfile, cols, lignes, maxval, 0 );
for (y = 0; y<lignes; y++){
pgm_writepgmrow(outfile, table2[y],cols, maxval, 0);
}
//release of space
for (y=0; y<lignes;y++){
pgm_freerow( table1[y] );
pgm_freerow( table2[y] );
}
free(table1);
free(table2);
pm_close( outfile );
pm_close( infile );
for(lala=0;lala<rmax;lala++){
delete accumulateur2[lala];
}
delete [] accumulateur2;
}