how to convert pixel intensities into values rgb values

asked 2014-03-14 02:41:33 -0600

shiv.butekar gravatar image

updated 2014-03-14 02:47:32 -0600

berak gravatar image
    i have following code 
    Mat image;
    image =initialize to CV_8CU3 ie bgr image
    ptr=(unsigned int *)image.data;
    cout<<*ptr;
    Now i will get a value of first pixel(example 2156890498 or 2222951812 or 2374403213)
    now i want to convert that value into RGB format so that i can convert that value into
    gray scale value  using formula (0.299R + 0.587G + 0.114B)
    how i can do that please provide solution 
    i am using cuda programming and opencv
    thanks in advance
edit retag flag offensive close merge delete

Comments

1

wait, this idea looks broken:

ptr=(unsigned int *)image.data;

no, you can't just cast to uint ( a bgr pixel is only 24 bits, not 32 ) and expect the result to be a32bit repr. of the pixel.

if you wanted a grayscale conversion, use cvtColor() instead

berak gravatar imageberak ( 2014-03-14 02:50:31 -0600 )edit

i am using cuda to to convert the image to gray hence i need a dirrect access to pixel values

shiv.butekar gravatar imageshiv.butekar ( 2014-03-14 03:20:29 -0600 )edit
1

yes, maybe. but not like this.

berak gravatar imageberak ( 2014-03-14 03:46:02 -0600 )edit