BGRA: color space in OpenCV

Image in OpenCV are in BGRA, not in RGBA!

Mat mat = imread("myimage.png");
for( int r = 0 ; r < mat.rows ; ++r )
{
    for( int c = 0 ; c < mat.cols ; ++c )
    {
        cv::Vec4b val = mat.at<cv::Vec4b>(r,c);
        char blue = val[0];
        char green = val[1];
        char red = val[2];
        char alpha = val[3];
       //do anything you want here...
    }
}

 

 


http://answers.opencv.org/question/8740/how-to-get-rgba8888-image-data-from-8uc4-matrix/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s