我是Opencl程序的新手,我编写了一个内核过滤器3 * 3的内核代码,但它没有在cpu中加载我总是有0作为值,我不知道原因。这是我的代码
uiRGBA[0] = pSrc[iPrev + x - 1];
uiRGBA[1] = pSrc[iPrev + x];
uiRGBA[2] = pSrc[iPrev + x + 1];
uiRGBA[3] = pSrc[iOffset + x - 1];
uiRGBA[4] = pSrc[iOffset + x];
uiRGBA[5] = pSrc[iOffset + x + 1];
uiRGBA[6] = pSrc[iNext + x - 1];
uiRGBA[7] = pSrc[iNext + x];
uiRGBA[8] = pSrc[iNext + x + 1];
uint uiResult = 0;
uint uiMask = 0xFF;
for(int ch = 0; ch < 3; ch++)
{
// extract next color channel
uint r0,r1,r2,r3,r4,r5,r6,r7,r8;
r0=uiRGBA[0]& uiMask;
r1=uiRGBA[1]& uiMask;
r2=uiRGBA[2]& uiMask;
r3=uiRGBA[3]& uiMask;
r4=uiRGBA[4]& uiMask;
r5=uiRGBA[5]& uiMask;
r6=uiRGBA[6]& uiMask;
r7=uiRGBA[7]& uiMask;
r8=uiRGBA[8]& uiMask;
//*ipSource, *ipDest
//neue Version des Filters
for(row = 0; row < height; row++)
{
for(col = 0; col < width; col++)
{
count++;
for(int i = max(0, row - radius); i < min(row + radius, height-1); i++)
{
for(int j = max(0, col-radius); j < min(col + radius , width-1); j++)
{
if((value = pSrc[j + i * width] ) != 0)
{
dMedianfield[++count] = value;
}
}
}
if(count)
{
pDst[row + col] = dMedianfield[++count];
}
}
}
}
pDst[col + row] = 8;
return;
} 在最后一行,我尝试在cpu中加载值8,但我改为0。