I am trying to solve a problem in which I have to change a color image to a grayscale image. For this, I use the CUDA parallel approach.
The kernel code that I invoke on the GPU is as follows.
__global__
void rgba_to_greyscale(const uchar4* const rgbaImage,
unsigned char* const greyImage,
int numRows, int numCols)
{
int absolute_image_position_x = blockIdx.x;
int absolute_image_position_y = blockIdx.y;
if ( absolute_image_position_x >= numCols ||
absolute_image_position_y >= numRows )
{
return;
}
uchar4 rgba = rgbaImage[absolute_image_position_x + absolute_image_position_y];
float channelSum = .299f * rgba.x + .587f * rgba.y + .114f * rgba.z;
greyImage[absolute_image_position_x + absolute_image_position_y] = channelSum;
}
void your_rgba_to_greyscale(const uchar4 * const h_rgbaImage,
uchar4 * const d_rgbaImage,
unsigned char* const d_greyImage,
size_t numRows,
size_t numCols)
{
const dim3 blockSize(numCols/32, numCols/32 , 1);
const dim3 gridSize(numRows/12, numRows/12 , 1);
rgba_to_greyscale<<<gridSize, blockSize>>>(d_rgbaImage,
d_greyImage,
numRows,
numCols);
cudaDeviceSynchronize(); checkCudaErrors(cudaGetLastError());
}
I see a line of dots in the first row of the pixel.
the error I get is
libdc1394 error: failed to initialize libdc1394
Position 51 difference exceeds acceptable level 5 Reference: 255
GPU: 0
my I / O images
Can anyone help me with this ??? thanks in advance.
source
share