Ask Your Question

asloob's profile - activity

2017-11-03 05:44:04 -0600 received badge  Notable Question (source)
2016-03-25 18:23:00 -0600 received badge  Popular Question (source)
2013-03-27 04:31:19 -0600 received badge  Scholar (source)
2013-03-08 05:49:26 -0600 commented answer How to get RGBA8888 image data from 8UC4 Matrix?

Thanks mathieu. I have tried to create a functiont to do this. Its still not working, can you have a look?

2013-03-08 01:35:35 -0600 received badge  Editor (source)
2013-03-08 00:41:41 -0600 asked a question How to get RGBA8888 image data from 8UC4 Matrix?

Hello, I am new to OpenCV. I need to get raw RGBA8888 image data from a Matrix in C++. The matrix is of type CvType.CV_8UC4 . Is this possible? Can anyone point me in the right direction? Or even better some sample code?

UPDATE I have created the following methods to da that with help from Mathiew. Is this correct?

void HelloWorld::convertBRGAtoRGBA(Mat mat, Mat dst)
{
    dst(mat); //create a copy
    for( int rowIndex = 0 ; rowIndex < mat.rows ; ++rowIndex )
    {
        for( int colIndex = 0 ; colIndex < mat.cols ; ++colIndex )
        {
            cv::Vec4b val = mat.at<cv::Vec4b>(rowIndex,colIndex);
        char blue = val[0];
        char green = val[1];
        char red = val[2];
        char alpha = val[3];
       //do anything you want here...
        dst.at<Vec4b>(rowIndex, colIndex)[0] = red;
        dst.at<Vec4b>(rowIndex, colIndex)[1] = green;
        dst.at<Vec4b>(rowIndex, colIndex)[2] = blue;
        dst.at<Vec4b>(rowIndex, colIndex)[3] = alpha;
    }
}
}