Hi!
I have an BGR image in device(cv::cuda::GpuMat) and I am passing this variable to my custom kernel function as cv::cuda::PtrStepSz. Below is the code of kernel.
__global__ void hist_mod(
int* BMap, int* GMap, int* RMap,
cv::cuda::PtrStepSz<uchar> input,
unsigned char* output,
int color_width_step,
int rows, int cols
){
int xidx = threadIdx.x + blockIdx.x*blockDim.x;
int yidx = threadIdx.y + blockIdx.y*blockDim.y;
if(xidx < cols && yidx < rows){
const int color_tid = yidx * color_width_step + xidx * 3; // location of the pixel in the image 3d
// const int gray_tid = yidx * cols + xidx; // location of the pixel in the image 2d
const unsigned char blue = input(yidx, xidx)[0];
const unsigned char green = input(yidx, xidx)[1];
const unsigned char red = input(yidx, xidx)[2];
output[color_tid] = (uchar)BMap[(int)blue];
output[color_tid + 1] = (uchar)GMap[(int)green];
output[color_tid + 2] = (uchar)RMap[(int)red];
}
}
My query is, as a 3 channel BGR Image, how to address inside the kernel?
const unsigned char blue = input(yidx, xidx)[0];
const unsigned char green = input(yidx, xidx)[1];
const unsigned char red = input(yidx, xidx)[2];