I'm loading a .png file using OpenCV and I want to extract its blue intensity values using thrust library.
My code goes like this:
- Loading an image using OpenCV 
IplImagepointer - Copying the image data into 
thrust::device_vector - Extracting the blue intensity values from the device vector inside a structure using thrust library.
 
Now I have a problem in extracting Blue Intensity values from the device vector.
- I did this code in cuda already now converting it using thrust library.
 - I fetch blue intensity values inside this function.
 - I want to know how to call this struct 
FetchBlueValuesfrom the main function. 
Code:
#define ImageWidth 14
#define ImageHeight 10
thrust::device_vector<int> BinaryImage(ImageWidth*ImageHeight);
thrust::device_vector<int> ImageVector(ImageWidth*ImageHeight*3);
struct FetchBlueValues
{
    __host__ __device__ void operator() ()
    {
        int index = 0 ;
        for(int i=0; i<= ImageHeight*ImageWidth*3 ; i = i+3)
        {
            BinaryImage[index]= ImageVector[i];
            index++;
        }
    }
};
void main()
{
    src = cvLoadImage("../Input/test.png", CV_LOAD_IMAGE_COLOR);
    unsigned char *raw_ptr,*out_ptr;
    raw_ptr = (unsigned char*) src->imageData;
    thrust::device_ptr<unsigned char> dev_ptr = thrust::device_malloc<unsigned char>(ImageHeight*src->widthStep);
    thrust::copy(raw_ptr,raw_ptr+(src->widthStep*ImageHeight),dev_ptr);
    int index=0;
    for(int j=0;j<ImageHeight;j++)
    {
        for(int i=0;i<ImageWidth;i++)
        {
            ImageVector[index] = (int) dev_ptr[ (j*src->widthStep) + (i*src->nChannels) + 0 ];
            ImageVector[index+1] = (int) dev_ptr[ (j*src->widthStep) + (i*src->nChannels) + 1 ];
            ImageVector[index+2] = (int) dev_ptr[ (j*src->widthStep) + (i*src->nChannels) + 2 ];
            index +=3 ;
        }
    }
}