Hello,

I’m a beginner with CUDA and I’m trying to implement the Hough transform.

The problem is that I use this function several times with the same parameters the result in imgOut is always different and I don’t understand why.

I think the problem comes from CurrentL and CurrentR but I don’t know why.

Can you explain me, please

```
//------------------------------------------------------------------------------
//Hough Transform Method
// @param imgOut
// @param imgIn : pointer inthe image in the devide
// @param nr:number of row
// @param nc:number of column
//------------------------------------------------------------------------------
Hough(int* imgOut, unsigned char* imgIn, int nr, int nc, int Pitch,int rmax, int angle_max)
{
int t = 200;
int yc, xc;
yc = (int)(nr/2);
xc = (int)(nc/2);
double rr = 0.0;
int ra;
double conv = 3.1415926535/180.0;
int CurrentR = 0;
int CurrentC = 0;
unsigned char * houghImg= (unsigned char *) (((char *) imgIn)+blockIdx.x*Pitch);
for ( int i = threadIdx.x; i < nc; i += blockDim.x )
{
if(houghImg[i] >= t)
{
CurrentR= 1+(i+blockIdx.x*Pitch)/nc;
CurrentC= (int)fmod((double)(i),(double)nc);
for(int alpha = 0; alpha < angle_max; alpha++)
{
rr =(double)(yc-CurrentR) * sin((double)(alpha*360/angle_max)*conv/2)+(double)(CurrentC-xc) * cos((double)(alpha*360/angle_max)*conv/2);
if(rr<0.0)
{
ra=(int)rr;
}
else
{
ra=(int)rr+1;
}
imgOut[alpha+((rmax+ra)*360)]++;
}
}
}
}
```