-1

I am trying to convert a RGB image to ARGB format. Is there any way to this in openCV? As far as I know, it is possible to convert the image to RGBA, but am not sure about ARGB.

This is what I am doing currently:

        cv::Mat argb(myImage.rows, myImage.cols, CV_8UC4);
        cv::Mat alpha(myImage.rows, myImage.cols, CV_8UC1);
        cv::Mat in[] = { myImage, alpha };
        int from_to[] = { 0,1,  1,2,  2,3,  3,0 };
        cv::mixChannels( in, 2, &argb, 1, from_to, 4 );

myImage is in 8uc3 format, which is my input image. But I need to change the format to ARGB for another application.

zghaf
  • 17
  • 4
  • 1
    What did you try to find your own answer? Please describe about it. This will help not only us to answer but yourself. – Tae-Sung Shin Aug 14 '13 at 19:20
  • Can you explain what you think the difference is between ARGB and RGBA? What problem are you actually trying to solve? – Retired Ninja Aug 14 '13 at 19:58
  • I edited my question to answer your questions. I need the Alpha channel to be in the left, since I have another application which ignores the alpha channel and process the image (so the image should be in ARGB format) – zghaf Aug 14 '13 at 21:31

1 Answers1

0

As far as i know cvtColor function doesn't provide such convertion, so you need to write it on your own - look at the source code of cvtColor function, your convertion will be quite similar to CV_BGR2RGB - you just need to switch first and last channel.

cyriel
  • 3,522
  • 17
  • 34