I've modified the Sobel Filter sample to implement Non-Max Suppression for Canny filter. However, the following code generates an exception:
unsigned char pix00 = pCannyOriginal[ i-1 + (blockIdx.x-1) * blockDim.x];
unsigned char pix01 = pCannyOriginal[ i+0 + (blockIdx.x-1) * blockDim.x];
unsigned char pix02 = pCannyOriginal[ i+1 + (blockIdx.x-1) * blockDim.x];
unsigned char pix10 = pCannyOriginal[ i-1 + (blockIdx.x+0) * blockDim.x];
unsigned char pix11 = pCannyOriginal[ i+0 + (blockIdx.x+0) * blockDim.x];
unsigned char pix12 = pCannyOriginal[ i+1 + (blockIdx.x+0) * blockDim.x];
unsigned char pix20 = pCannyOriginal[ i-1 + (blockIdx.x+1) * blockDim.x];
unsigned char pix21 = pCannyOriginal[ i+0 + (blockIdx.x+1) * blockDim.x];
unsigned char pix22 = pCannyOriginal[ i+1 + (blockIdx.x+1) * blockDim.x];
I understand that this causes invalid access to memory, but the same set of assignments on the original texture wouldn't generate one. So, does the tex2D function have a mechanism for invalid memory access? And how am I supposed to fix this?
Also as a note, using the original lena.pgm wouldn't generate any exception, but replacing it with something else does. Does the original lena.pgm contain some extra rows and columns or am I missing something here?