colored image to greyscale image using CUDA parallel processing

前端 未结 12 1235
失恋的感觉
失恋的感觉 2021-02-04 19:10

I am trying to solve a problem in which i am supposed to change a colour image to a greyscale image. For this purpose i am using CUDA parallel approach.

The kerne code i

12条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 20:06

    const dim3 blockSize(16, 16, 1);  //TODO
    const dim3 gridSize( (numRows+15)/16, (numCols+15)/16, 1);  //TODO
    
    int x = blockIdx.x * blockDim.x + threadIdx.x;  
    int y = blockIdx.y * blockDim.y + threadIdx.y;
    
    uchar4 rgba = rgbaImage[y*numRows + x];
    float channelSum = .299f * rgba.x + .587f * rgba.y + .114f * rgba.z;
    greyImage[y*numRows + x] = channelSum;
    

提交回复
热议问题