colored image to greyscale image using CUDA parallel processing

前端 未结 12 1428
失恋的感觉
失恋的感觉 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 19:55

    Since you are not aware of the image size. It is best to choose any reasonable dimension of the two-dimensional block of threads and then check for two conditions. The first one is that the pos_x and pos_y indexes in the kernel do not exceed numRows and numCols. Secondly the grid size should be just above the total number of threads in all the blocks.

    const dim3 blockSize(16, 16, 1);
    const dim3 gridSize((numCols%16) ? numCols/16+1 : numCols/16,
    (numRows%16) ? numRows/16+1 : numRows/16, 1);
    

提交回复
热议问题